#pragma mark 为CALayer+CAAnimation 准备视图
self.customLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
_customLabel1.backgroundColor = [UIColor cyanColor];
[self.view addSubview:_customLabel1];
self.customView = [[UIView alloc]initWithFrame:CGRectMake(200, 200, 100, 150)];
_customView.backgroundColor = [UIColor magentaColor];
[self.view addSubview:_customView];
===========================
#pragma mark 模拟 动画
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//CALayer 影响属性:cornerRadius圆角、shadowolor阴影颜色、ShadowOffset阴影偏移距离、ShadowRadius阴影模糊程度、ShadowOpacit阴影透明度、BorderWidth描边粗细、BorderColor描边颜色、anchorPoint锚点、position位置信息、transform使CALayer产生3D空间内的平移.缩放.旋转等变化。
#pragma mark CABasicAnimation
//这里的keyPath需要强打
CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
//设定变换初始值 都是id对象类型的,所以用字面量。
basicAnimation.fromValue = @0;
//设定变换后的结束值
basicAnimation.toValue = @(M_PI_4);
//设定动画间隔
basicAnimation.duration = 4;
//必须把动画添加到layer层上
//这里的key是随便取的,主要是因为移除动画的时候,需要用到这个key。
[_customView.layer addAnimation:basicAnimation forKey:@"basic"];
//解决旋转后要回到原始位置。--思想就是在动画刚好结束后,让他停在这个角度上。
[self performSelector:@selector(stain) withObject:nil afterDelay:4];
=========================
-(void)stain
{
_customView.transform = CGAffineTransformRotate(_customView.transform, M_PI_4);
}