Hello, everyone.
I'm in a bit of a hurdle. I am trying to place a UIView on top of a MKMapView, but the view should have a blur effect, so that the map shines through the blur a bit. However, doing this results in the UIView blocking the legal label of the map, and so my app will be rejected from the App Store.
So, my question is, how do i move the legal label? I have tried creating a subclass for MKMapView, and then repositioning the label from there, but this does not seem to work with iOS 11. Here's that piece of code:
class MapViewSubclass: MKMapView {
override func layoutSubviews() {
super.layoutSubviews()
let legalLabel = self.subviews[1]
legalLabel.center = CGPoint(x: legalLabel.center.x, y: legalLabel.center.y - 80)
}
}
What I am trying to achieve is somthing like this: https://developer.apple.com/ios/human-interface-guidelines/views/maps/
On the left-most iPhone X you see that the map exends behind the bar in the bottom, but the legal label is still visible on top of the bottom bar.
I am doing this in Swift 4, Xcode 9, and it is an iOS 11 app.
Thnak you 🙂
1. Constrain the bottom of your map view to the bottom of its superview (the view controller's view).
2. Constrain the bottom of your visual effect view to the bottom of its superview (the view controller's view).
3. Set the bottom safe area to include the visual effect view's height. Like this:
override func viewDidLoad() {
super.viewDidLoad()
additionalSafeAreaInsets = UIEdgeInsetsMake(0.0, 0.0, bottomView.bounds.height, 0.0)
// If you need support for iOS 10, you should use bottomLayoutGuide instead.
}
Here's a screenshot of what this looks like (remove the space in the URL):
https ://postimg.org/image/8pee2b52z/