写在一个View的类别中的方法 直接上代码与效果

- (void)setYRotation:(CGFloat)degrees anchorPoint:(CGPoint)point perspectiveCoeficient:(CGFloat)m34 {
CATransform3D transfrom = CATransform3DIdentity;
transfrom.m34 = 1.0 / m34;
CGFloat radiants = degrees / 360.0 * 2 * M_PI;
transfrom = CATransform3DRotate(transfrom, radiants, 0.0f, 1.0f, 0.0f);
CALayer *layer = self.layer;
layer.anchorPoint = point;
layer.transform = transfrom;
}
- (void)setYRotation:(CGFloat)degrees {
[self setYRotation:degrees anchorPoint:CGPointMake(0, 0) perspectiveCoeficient:800];
}

基本和Y类似 就是将要修改的y 位置改为0 将x位置改为1
- (void)setXRotation:(CGFloat)degrees {
[self setXRotation:degrees anchorPoint:CGPointMake(0.5, 0.5) perspectiveCoeficient:800];
}
- (void)setXRotation:(CGFloat)degrees anchorPoint:(CGPoint)point perspectiveCoeficient:(CGFloat)m34 {
CATransform3D transfrom = CATransform3DIdentity;
transfrom.m34 = 1.0 /m34;
CGFloat radiants = degrees / 360.0 * 2 * M_PI;
transfrom = CATransform3DRotate(transfrom, radiants, 1.0f, 0.0f, 0.0f);
CALayer *layer = self.layer;
layer.anchorPoint = point;
layer.transform = transfrom;
}
网友评论