CALayer相关知识点记录
2022-12-04 本文已影响0人
恋空K
[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"];
}];








UIView的center属性就是其内部layer的position属性,修改UIView的center属性和修改其内部layer的
position属性,都是修改同一个值。只是修改方式不一样

