Setting the zoom level for a MKMapView

后端 未结 15 3052
不知归路
不知归路 2020-12-02 05:46

I have a map which shows correctly, the only thing I want to do now is set the zoom level when it loads. Is there a way to do this?

Thanks

15条回答
  •  情话喂你
    2020-12-02 05:51

    A simple Swift implementation, if you use outlets.

    @IBOutlet weak var mapView: MKMapView! {
        didSet {
            let noLocation = CLLocationCoordinate2D()
            let viewRegion = MKCoordinateRegionMakeWithDistance(noLocation, 500, 500)
            self.mapView.setRegion(viewRegion, animated: false)
        }
    }
    

    Based on @Carnal's answer.

提交回复
热议问题