问题描述
- 简单UIView的核心动画3D转换
-
我正在做关于CA的部分翻转动画。但是在透视的时候遇到问题。代码:
[UIView animateWithDuration:1.0 animations:^{ self.someView.layer.anchorPoint = CGPointMake(0.5, 0); self.someView.layer.transform = CATransform3DMakeRotation(M_PI*0.6,1.0,0.0,0.0); } completion:^(BOOL finished){ // code to be executed when flip is completed }];
怎么样得到这样的透视图?
解决方案
比如像这样?
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / 300;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI * 0.6, 1.0f, 0.0f, 0.0f);
[UIView animateWithDuration:1.0 animations:^{
self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
self.someView.layer.transform = rotationAndPerspectiveTransform;
} completion:^(BOOL finished){
// code to be executed when flip is completed
}];
时间: 2024-09-25 13:20:04