How do you move the legal sign in mapview

后端 未结 11 2044
别跟我提以往
别跟我提以往 2020-12-05 20:24

I wonder if anyone know how you move the legal sign on a mapview, right now my toolbar is covering it. Does anyone know how? There is lot\'s of help with the google logo but

相关标签:
11条回答
  • 2020-12-05 20:46

    This should work, although I'm not sure whether Apple will allow you to do that

    UILabel *attributionLabel = [mapView.subviews objectAtIndex:1];
    attributionLabel.center = CGPointMake(attributionLabel.center.x, attributionLabel.center.y - 44.0f);
    
    0 讨论(0)
  • 2020-12-05 20:47

    A Swift 3 example based on @xeieshan's example that works when compiled against iOS 10 SDK. In my example I have a transparent bar in the bottom that animates up when the map view is being present. The label repositioning can also be animated.

    // 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                                                                     
    0 讨论(0)
  • 2020-12-05 20:47

    Use viewWillLayoutSubviews() instead of viewDidAppear() to avoid a jump.

    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)
    }
    
    0 讨论(0)
  • 2020-12-05 20:48

    In Swift:

    mapView.layoutMargins = UIEdgeInsetsMake(top, right, -20, left)
    

    I tested this in OS9 and it works.

    Swift 5.2

    // -20 will make the legal disclaimer move down. If you want the
    // disclaimer to move up, use a positive number.
    mapView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: -20, right: 0)
    
    0 讨论(0)
  • 2020-12-05 20:50

    Changing the position doesn't quite work, however hiding the "Legal" button works perfectly.

    [[mapView.subviews objectAtIndex:1] setHidden:YES]

    EDIT:

    Swift 2.0 iOS equivalent

    mapView.subviews[1].isHidden = true

    0 讨论(0)
提交回复
热议问题