私はかなり長い間マップの置換に取り組んできました。全体はUIScrollView
で、CATiledLayer
に裏打ちされています。UIScrollView setZoomScaleは、適用された回転を0に戻します。
マップを回転するには、レイヤー自体を回転させます。 (CATransform3DMakeRotation
を使用して)今のところかなりうまく動作します=)
しかし、私は今まで私の層に提出されようとしているCATransform3D
は、私の質問は、ありさ0
に回転をリセットしてsetZoomScale
メソッドを呼び出す場合適用された回転を失うことなく、私のscrollViewの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];
}
}
ちょっとBartosz、まず、そのポストに感謝します!しかし、それは私のためには機能しませんでした...私はアンカーポイントを編集して現在の位置を中心に回転させました。多分それは問題ですか?投稿を編集してそのコードを追加します。 –
それは回転を保持しましたが、回転軸が間違っていました。 –
私は本当に分からない。ちょうど私が見るものから、それは奇妙な点の周りに多く回転します。しかし、軸は正しいようです。 –