动画-图片旋转

本文介绍如何使用 Core Animation 在 iOS 应用中实现 UIImageView 的旋转动画效果,并提供了暂停动画的方法。通过设置 CABasicAnimation 并应用 CATransform3D 实现了无限循环的旋转动画。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

旋转:

iv = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 300, 300)];
[iv setImage:[UIImage imageNamed:@"dial_panel"]];
//CALayer *rotate_layer = iv.layer;
[self.view addSubview:iv];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.delegate = self;
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI , 0, 0, 1.0)];
animation.duration = 1;
animation.cumulative = YES;
animation.repeatCount = INT_MAX;
animation.speed = 10;
[iv.layer addAnimation:animation forKey:@"animation"];

暂定:

CFTimeInterval pausedTime = [iv.layer convertTime:CACurrentMediaTime() fromLayer:nil];
iv.layer.speed = 0.0;
iv.layer.timeOffset = pausedTime;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值