gpt4 book ai didi

ios - 向下或向上滑动 MKMapView 指定数量的像素

转载 作者:行者123 更新时间:2023-11-28 06:23:28 26 4
gpt4 key购买 nike

我如何将 MKMapView 垂直滑动给定的像素数,我玩了一下,这是我的代码,当然这不起作用:(

var point = mapView.convert(mapView.centerCoordinate, toPointTo: self.view)

point.x += offSet.x
point.y += offSet.y

let center = mapView.convert(point, toCoordinateFrom: self.view)
mapView.setCenter(center, animated: true)

最佳答案

刚刚弄明白了,这是代码,希望它能帮助别人;)

func mapViewMoveBy(offset: CGPoint, animated: Bool = true) {
var point = mapView.center

point.x += offset.x
point.y += offset.y

let coordinate = mapView.convert(point, toCoordinateFrom: mapView)
mapView.setCenter(coordinate, animated: animated)
}

用法

let slideFourtyPixelDown: CGFloat = -40
mapViewMoveBy(offset: CGPoint(x: 0, y: slideFourtyPixelDown))

关于ios - 向下或向上滑动 MKMapView 指定数量的像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42673110/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com