我一直在研究地图替换很长一段时间。整个事情在 a 的UIScrollView
支持下工作CATiledLayer
。
要旋转我的地图,我会旋转图层本身。(使用CATransform3DMakeRotation
)到目前为止效果很好=)
但是,如果我调用setZoomScale
方法CATransform3D
,将提交到我的图层的方法是将旋转重置为 0。
我的问题是,有没有办法在zoomscale
不丢失应用旋转的情况下设置我的滚动视图?
捏合手势也存在同样的问题。
//附加信息
要围绕当前位置旋转,我必须编辑锚点。也许这也是缩放的问题。
- (void)correctLayerPosition {
CGPoint position = rootView.layer.position;
CGPoint anchorPoint = rootView.layer.anchorPoint;
CGRect bounds = rootView.bounds;
// 0.5, 0.5 is the default anchorPoint; calculate the difference
// and multiply by the bounds of the view
position.x = (0.5 * bounds.size.width) + (anchorPoint.x - 0.5) * bounds.size.width;
position.y = (0.5 * bounds.size.height) + (anchorPoint.y - 0.5) * bounds.size.height;
rootView.layer.position = position;
}
- (void)onFinishedUpdateLocation:(CLLocation *)newLocation {
if (stayOnCurrentLocation) {
[self scrollToCurrentPosition];
}
if (rotationEnabled) {
CGPoint anchorPoint = [currentConfig layerPointForLocation:newLocation];
anchorPoint.x = anchorPoint.x / rootView.bounds.size.width;
anchorPoint.y = anchorPoint.y / rootView.bounds.size.height;
rootView.layer.anchorPoint = anchorPoint;
[self correctLayerPosition];
}
}