2016-07-28 6 views
1

J'ai tout essayé pour faire apparaître ma vue sur la carte (voir le code ci-dessous), mais elle n'apparaîtra toujours pas. Je ne sais pas quoi faire. This is the mapView at 0.5 alphaVue bloquée derrière 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) 

Lorsque j'utilise la position z, la vue semble, mais il ne permet pas d'actions tactiles (il est une coutume contrôle segmenté).

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

Je l'ai déjà regardé ce fil: [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-other-views) – CarvicheBlack

Répondre

1

Avez-vous essayé l'une de ces solutions?

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

ou

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

Merci. Le deuxième a travaillé. J'ai cherché partout pour cela. :) – CarvicheBlack