2016-07-28 7 views
1

Ich habe alles versucht, um meine Ansicht über die Kartenansicht erscheinen zu lassen (siehe Code unten), aber es wird immer noch nicht angezeigt. Ich weiß nicht, was ich machen soll. This is the mapView at 0.5 alphaView stecken fest hinter MapView

segmentedControl = DPSegmentedControl.init(
      FrameWithoutIcon: CGRectMake(307.5, 566, 235, 37.5), 
      items: ["Standard", "Satellite", "Hybrid"], 
      backgroundColor: UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1), 
      thumbColor: UIColor.init(hex: "#B60002"), 
      textColor: UIColor(hex: "#808080"), 
      selectedTextColor: UIColor(hex: "#FFFFFF")) 
     segmentedControl.alpha = 0 

     segmentedControl.selectedIndex = 0 

     segmentedControl.addTarget(self, action: #selector(self.tapSegment(_:)), forControlEvents: .ValueChanged) 
     self.view.insertSubview(self.segmentedControl, belowSubview: self.hoverBar) 
     UIApplication.sharedApplication().keyWindow!.bringSubviewToFront(self.segmentedControl) 
     UIApplication.sharedApplication().keyWindow!.sendSubviewToBack(self.mapView) 

Wenn ich z-Position verwenden, erscheint die Ansicht, aber es erlaubt keine Berührungsaktionen (es wird eine individuelle Steuerung segmentiert).

self.segmentedControl.layer.zPosition = self.mapView.layer.zPosition + 1 
+0

Ich habe bereits auf diesen Thread sah: [https://stackoverflow.com/questions/13182482/bringing-a-subview-to-be-in-front-of -all-other-views] (https://stackoverflow.com/questions/13182482/bringing-a-subview-to-be-in-front-of-all-other-views) – CarvicheBlack

Antwort

1

Haben Sie beides versucht?

self.view.bringSubviewToFront(self.segmentedControl) 
self.view.sendSubviewToBack(self.mapView) 

oder

self.segmentedControl?.superview.bringSubviewToFront(self.segmentedControl) 
self.mapView?.superview.sendSubviewToBack(self.mapView) 
+0

Vielen Dank. Der zweite hat funktioniert. Ich habe überall danach gesucht. :) – CarvicheBlack