CATransform3Dにてアニメーションをしたのち、変換を戻すために逆値を入れてみましたが多少のズレが生じてしまいます。
CATransform3Dで変換した座標等を戻すような方法はありますか?
swift
1 var rotationWithPerspective = CATransform3DIdentity 2 rotationWithPerspective.m34 = -1.0/500.0/4 3 4 /// これだけ座標変換します。 5 let radians: CGFloat = 20.0 * .pi / 180 6 rotationWithPerspective = CATransform3DRotate(rotationWithPerspective, radians, -1.00, 0, 0) 7 rotationWithPerspective = CATransform3DTranslate(rotationWithPerspective, 0, 100, -100) 8 UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, options: .curveEaseInOut, animations: { 9 fromView?.layer.transform = rotationWithPerspective 10 }, completion: { _ in 11 let wasCanceled = transitionContext.transitionWasCancelled 12 transitionContext.completeTransition(!wasCanceled) 13 /// アニメーション終了後変換した座標を戻すために逆の値を入力します。 14 /// 結果がだいぶずれてしまいます。 15 rotationWithPerspective = CATransform3DRotate(rotationWithPerspective, radians, 1.00, 0, 0) 16 rotationWithPerspective = CATransform3DTranslate(rotationWithPerspective, 0, -100, 100) 17 fromView?.layer.transform = rotationWithPerspective 18 })
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/04 16:25