CATransform3DRotate 实现左右,上下翻转效果

时间:2022-06-19 08:11:34
 
 

CGFloat m34 = 800;

CGFloat value = -40;//(控制翻转角度)

CGPoint point = CGPointMake(0.5, 0.5);//设定翻转时的中心点,0.5为视图layer的正中

CATransform3D transfrom = CATransform3DIdentity;

transfrom.m34 = 1.0 / m34;

CGFloat radiants = value / 360.0 * 2 * M_PI;

transfrom = CATransform3DRotate(transfrom, radiants, 1.0f, 0.0f, 0.0f);//(后面3个 数字分别代表不同的轴来翻转,本处为x轴)

CALayer *layer = self.panView.layer;

layer.anchorPoint = point;

layer.transform = transfrom;