视图卡在 MapView 后面
View stuck behind MapView
我已尽一切努力使我的视图显示在地图视图上(请参阅下面的代码),但它仍然不会显示。我不知道该怎么办。 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)
当我使用 z 位置时,视图出现,但它不允许任何触摸操作(它是一个自定义分段控件)。
self.segmentedControl.layer.zPosition = self.mapView.layer.zPosition + 1
你试过这些吗?
self.view.bringSubviewToFront(self.segmentedControl)
self.view.sendSubviewToBack(self.mapView)
或
self.segmentedControl?.superview.bringSubviewToFront(self.segmentedControl)
self.mapView?.superview.sendSubviewToBack(self.mapView)
我已尽一切努力使我的视图显示在地图视图上(请参阅下面的代码),但它仍然不会显示。我不知道该怎么办。 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)
当我使用 z 位置时,视图出现,但它不允许任何触摸操作(它是一个自定义分段控件)。
self.segmentedControl.layer.zPosition = self.mapView.layer.zPosition + 1
你试过这些吗?
self.view.bringSubviewToFront(self.segmentedControl)
self.view.sendSubviewToBack(self.mapView)
或
self.segmentedControl?.superview.bringSubviewToFront(self.segmentedControl)
self.mapView?.superview.sendSubviewToBack(self.mapView)