[UIView animateWithDuration:0.5 animations:^{
//旋转
self.imageView.layer.transform = CATransform3DMakeRotation(M_PI, 1, 1, 0);
//平移
self.imageView.layer.transform = CATransform3DMakeTranslation(50, 50, 0);
self.imageView.layer.transform = CATransform3DTranslate(self.imageView.layer.transform, 50, 50, 0);
//缩放
self.imageView.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1);
//把结构体转成对象
//KVC使用场景,用来做快速形变操作,只做一个值的操作
NSValue *valeu = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 1, 1, 0)];
[self.imageView.layer setValue:valeu forKeyPath:@"transform"];
[self.imageView.layer setValue:@(100) forKeyPath:@"transform.translation.x"];
}];

这样设置图片,不需要指定大小,图片会直接填充整个layer

position的默认值是父控件的左上角(0,0)那个点。position点跟锚点自始至终都是重合的
UIView的center属性就是其内部layer的position属性,修改UIView的center属性和修改其内部layer的
position属性,都是修改同一个值。只是修改方式不一样

事务的一个概念
网友评论