1、结构体转换成对象
CALayer的形变就要利用到它
#pragma mark - CALayer的形变
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
/*
Returns a transform that rotates by 'angle' radians about the vector '(x, y, z)'.
x 上下旋转;y 左右旋转,z 绕垂直屏幕的方向旋转
*/
[UIView animateWithDuration:2 animations:^{
//旋转
// [self.imageView.layer setTransform:CATransform3DMakeRotation(M_PI, 1, 1, 0)];//(0,0,1),(0,0,0)构成一个Z轴的向量
//收放
// [self.imageView.layer setTransform:CATransform3DScale(self.imageView.layer.transform, 0.5, 0.5, 0.5)];
//平移
// [self.imageView.layer setTransform:CATransform3DTranslate(self.imageView.layer.transform, 10, 10, 10)];
//KVC
[self.imageView.layer setValue:[NSValue valueWithCATransform3D:CATransform3DTranslate(self.imageView.layer.transform, 20, 20, 20)] forKeyPath:@"transform"];
//[self.imageView.layer setValue:@M_PI forKeyPath:@"transform.rotation"];
}];
}
transform的属性列表:
作者:u011018979 发表于2017/7/2 16:47:28 原文链接
阅读:54 评论:0 查看评论