view围绕圆心自转
创建一个image
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(40, 50, 200, 200)]; imgView.image = [UIImage imageNamed:@"image"]; [self.view addSubview:imgView];
创建一个基础动画
CABasicAnimation *animation = [CABasicAnimation new];
设置动画要改变的属性
animation.keyPath = @"transform.rotation.z"; //animation.fromValue = @(_bgImgV.layer.transform.m11);
动画的最终属性的值(转7.5圈)
animation.toValue = @(M_PI*1);
动画的播放时间
animation.duration = 3;
动画效果慢进慢出
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
解决动画结束后回到原始状态的问题
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
将动画添加到imgView的layer上
[imgView.layer addAnimation:animation forKey:@"rotation"];