Я уже давно работаю над заменой карт. Все это работает с UIScrollView
, поддерживаемым CATiledLayer
.
Чтобы повернуть карту, я поворачиваю сам слой. (ИспользованиеCATransform3DMakeRotation
)Пока работает довольно хорошо =)
Но если я когда-нибудь вызову метод setZoomScale
, CATransform3D
, который будет отправлен моему слою, сбрасывает вращение на 0.
Мой вопрос: есть ли способ установить zoomscale
моего scrollView без потери примененного поворота?
Та же проблема существует и для жестов щипка.
//Дополнительная информация
Чтобы вращаться вокруг текущей позиции, мне нужно отредактировать точку привязки. Возможно, это проблема и для масштабирования.
- (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];
}
}