Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UILabel *attributionLabel = [mapView.subviews objectAtIndex:1];
- attributionLabel.center = CGPointMake(attributionLabel.center.x, attributionLabel.center.y - 44.0f);
- mapView.layoutMargins = UIEdgeInsetsMake(top, right, -20, left)
- UILabel *attributionLabel = [mapView.subviews objectAtIndex:1];
- attributionLabel.center = CGPointMake(attributionLabel.center.x, attributionLabel.center.y - 44.0f);
- UILabel *attributionLabel = [mapView.subviews objectAtIndex:1];
- attributionLabel.frame = CGRectMake(20, self.view.frame.size.height - 135, attributionLabel.frame.size.width, attributionLabel.frame.size.height);
- \135 is height of your bottom view that was hiding legal
- // reposition the 'Legal' label above the transparent bottom bar
- // unfortunately there is no safe way to identify the label but it is the last subview - hopefully this will not change 😱
- if let legalLabel = mapView.subviews.last {
- var frame = legalLabel.frame
- frame.origin.y = frame.origin.y - self.bottomBar.bounds.size.height // reposition it above the bottom bar
- legalLabel.frame = frame
- }
- import MapKit
- extension MKMapView {
- /// Workaround for layoutMargins bug.
- func setLegalInsets(left: CGFloat, bottom: CGFloat) {
- let oldLeft = layoutMargins.left
- let oldBottom = layoutMargins.bottom
- let lblLegal = (subviews.filter { view in
- return view is UILabel
- }).first
- lblLegal?.frame.origin.x += left - oldLeft
- lblLegal?.frame.origin.y -= bottom - oldBottom
- layoutMargins.left = left
- layoutMargins.bottom = bottom
- }
- }
- override func viewWillLayoutSubviews() {
- positionLegalMapLabel()
- }
- func positionLegalMapLabel() {
- let legalMapLabel = self.mapView.subviews[1]
- legalMapLabel.frame.origin = CGPointMake(self.mapView.bounds.size.width - legalMapLabel.frame.size.width - 7, legalMapLabel.frame.origin.y)
- }
- override func viewWillLayoutSubviews() {
- positionLegalMapLabel()
- }
- func positionLegalMapLabel() {
- if self.mapView.subviews.count > 1 {
- let legalMapLabel = self.mapView.subviews[1]
- legalMapLabel.frame.origin = CGPointMake(self.mapView.bounds.size.width - legalMapLabel.frame.size.width - 7, legalMapLabel.frame.origin.y)
- }
- }
Add Comment
Please, Sign In to add comment