//开始选号
- (IBAction)startChoose {
//停掉定时器
[self stopRotating];
//核心动画-基础动画
CABasicAnimation *anim = [CABasicAnimation animation];
anim.keyPath = @"transform.rotation";
anim.toValue = @(2 * M_PI * 3);
anim.duration = 1.5;
// anim.repeatCount = 3;
//开始和结尾比较慢,中间快
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.delegate = self;
[self.centerWheel.layer addAnimation:anim forKey:nil];
//不能被点击
self.userInteractionEnabled = NO;
}
//动画停止之后执行
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
self.userInteractionEnabled = YES;
//2秒后执行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//调用开始转动的方法
[self statrRotating];
});
}
核心动画——基础动画
最新推荐文章于 2022-04-21 20:46:30 发布