您的位置:首页 > 移动开发 > IOS开发

【iOS开发】仿QQ音乐头像旋转

2016-12-09 11:20 253 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: