头像前后旋转)"/>
图片前后旋转(头像前后旋转)
最近看到了用户的头像可以前后旋转,还是蛮酷炫的就写了段实现方法, 给需要帮助的人吧。
// 头像动画[self rotate360WithDuration:2.0 repeatCount:1];_headImageView.animationDuration = 2.0;_headImageView.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"profileFansV2"],[UIImage imageNamed:@"profileCartListV2"],[UIImage imageNamed:@"profileCartListV2"],[UIImage imageNamed:@"profileCartListV2"],[UIImage imageNamed:@"profileCartListV2"],[UIImage imageNamed:@"profileFansV2"], nil];_headImageView.animationRepeatCount = 1;[_headImageView startAnimating];
- (void)rotate360WithDuration:(CGFloat)aDuration repeatCount:(CGFloat)aRepeatCount
{CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animation];theAnimation.values = [NSArray arrayWithObjects:[NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,1,0)],[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0,1,0)],[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0,1,0)],[NSValue valueWithCATransform3D:CATransform3DMakeRotation(2*M_PI, 0,1,0)],nil];theAnimation.cumulative = YES;theAnimation.duration = aDuration;theAnimation.repeatCount = aRepeatCount;theAnimation.removedOnCompletion = YES;[_headImageView.layer addAnimation:theAnimation forKey:@"transform"];
}
更多推荐
图片前后旋转(头像前后旋转)
发布评论