简体   繁体   中英

How to apply transform in UIView?

I have applied below transform to UIView's layer like this:

 CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
 rotationAndPerspectiveTransform.m34 = 1.0 / -850;
 rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI_4*1.1,0.0f, 1.2f, 0.0f);
 self.centerView.layer.transform = rotationAndPerspectiveTransform;

But not so much success i just wanted to apply transform like shown below image 在此输入图像描述

Any help would so much appreciated. Thanks for reading my Question

Maybe this could be helpful

CATransform3D t1 = CATransform3DIdentity;
t1.m34 = 1.0/-850;
t1 = CATransform3DScale(t1, 0.95, 0.95, 1);
t1 = CATransform3DRotate(t1, 15.0f*M_PI_4/180.0f, 0, 1.2, 0);

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValue valueWithCATransform3D:t1];
animation.duration = 1;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM