1

I have tried everything to make my view appear over the map view (see code below), but it still won't show up. I don't know what to do. This is the mapView at 0.5 alpha

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)

When I use z position, the view appears, but it does not allow any touch actions (it is a custom segmented control).

self.segmentedControl.layer.zPosition = self.mapView.layer.zPosition + 1
  • I have already looked at this thread: [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) –  Jul 28 '16 at 15:01

1 Answers1

0

Have your tried either of these?

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

or

self.segmentedControl?.superview.bringSubviewToFront(self.segmentedControl)
self.mapView?.superview.sendSubviewToBack(self.mapView)
richy
  • 2,716
  • 1
  • 33
  • 42
  • Thank you. The second one worked. I have been searching all over for this. :) –  Jul 28 '16 at 21:55