UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 50, 100, 100)];
imageView.layer.masksToBounds = YES;
imageView.layer.cornerRadius = imageView.frame.size.width / 2;
[imageView setImage:[UIImage imageNamed:@"111.png"]];
imageView.backgroundColor = [UIColor redColor];
int direction = 1; //-1为逆时针
// 动画
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * direction];
rotationAnimation.duration = 4.0f;
rotationAnimation.repeatCount = HUGE_VALF;
// rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[imageView.layer addAnimation:rotationAnimation forKey:@"rotateAnimation"];
[self.view addSubview:imageView];
imageView.center = self.view.center;
【iOS开发】仿QQ音乐头像旋转
最新推荐文章于 2020-10-13 13:02:13 发布