图片前后旋转(头像前后旋转)

编程入门 行业动态 更新时间:2024-10-23 09:29:30

图片前后旋转(<a href=https://www.elefans.com/category/jswz/34/1766089.html style=头像前后旋转)"/>

图片前后旋转(头像前后旋转)

最近看到了用户的头像可以前后旋转,还是蛮酷炫的就写了段实现方法, 给需要帮助的人吧。

// 头像动画[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"];
}


更多推荐

图片前后旋转(头像前后旋转)

本文发布于:2023-07-01 07:35:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/972700.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:头像   图片

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!