How do you move the legal sign in mapview

后端 未结 11 2054
别跟我提以往
别跟我提以往 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:41

    I wrote extension that worked for me. It can be used in animation block to animate those changes:

    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
      }
    }
    

提交回复
热议问题