CATransform3D 使用

struct CATransform3D

{

CGFloat m11(x轴缩放), m12(y轴切变), m13, m14(x轴拉伸);

CGFloat m21(x轴切变), m22(y轴缩编), m23, m24(向y轴拉伸);

CGFloat m31, m32, m33, m34;

CGFloat m41(x轴平移), m42(y轴平移), m43(z轴平移), m44(放大);

};

举例:

对照图

UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

img.image = [UIImage imageNamed:@"11"];

[self.view addSubview:img];

修改图

UIImageView *caimg = [[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)];

caimg.image = [UIImage imageNamed:@"11"];

[self.view addSubview:caimg];

1、平行移动

CATransform3DMakeTranslation(tx,ty,tz)

tx:x轴方向移动,右移为正数

ty:y轴方向移动,下移为正数

tz:z轴方向移动,外移为正数

CATransform3D translation = CATransform3DMakeTranslation(0.0, 80.0, 5.0);

caimg.layer.transform = translation;

2、缩放

CATransform3DMakeScale(CGFloat sx, CGFloat sy, CGFloat sz)

sx:x轴方向缩放,大于1放大。小于1缩小

sy:y轴方向缩放,大于1放大。小于1缩小

sz:z轴方向缩放,大于1放大。小于1缩小

CATransform3D scale = CATransform3DMakeScale(2, 2, 5);

  caimg.layer.transform = scale;

3、旋转

CATransform3DMakeRotation (CGFloat angle, CGFloat x,CGFloat y, CGFloat z)

angle:旋转角度

x:围绕x轴旋转,取值范围-1~1

y:围绕y轴旋转,取值范围-1~1

z:围绕z轴旋转,取值范围-1~1

CATransform3D rotation = CATransform3DMakeRotation(M_PI/3, 1, 1, 1); caimg.layer.transform = rotation;

4、复合行

CATransform3DIsIdentity (CATransform3D t)

t:CATransform3D类型,可以附加

CATransform3DTranslate (CATransform3D t, CGFloat tx,

CGFloat ty, CGFloat tz)

CATransform3DScale (CATransform3D t, CGFloat sx,

CGFloat sy, CGFloat sz)

 

转载于:https://www.cnblogs.com/pjfeng/p/8981762.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值