您好,登錄后才能下訂單哦!
(翻轉)方式一:
[NSTimer scheduledTimerWithTimeInterval:3.f repeats:YES block:^(NSTimer * _Nonnull timer) { CABasicAnimation* rotationAnimation = [CABasicAnimation animation];; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ]; rotationAnimation.duration = 1; // 切換界面保證動畫不停止 rotationAnimation.removedOnCompletion = NO; rotationAnimation.repeatCount = 1; [self.bindCardImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; }];
(翻轉)方式二(這種方式較好一些):
CABasicAnimation *waitAnimation = [CABasicAnimation animation]; waitAnimation.toValue = [NSNumber numberWithFloat:1.0]; waitAnimation.duration = 3.f; waitAnimation.beginTime = 3.f; CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ]; rotationAnimation.duration = 1.f; CAAnimationGroup *group = [CAAnimationGroup animation]; group.duration = 4.f; group.repeatCount = CGFLOAT_MAX; group.removedOnCompletion = NO; [group setAnimations:@[waitAnimation, rotationAnimation]]; [self.bindCardImageView.layer addAnimation:group forKey:@"bindCardImageViewAnimation"];
抖動:
CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; //設置抖動幅度 shake.fromValue = [NSNumber numberWithFloat:-0.2]; shake.toValue = [NSNumber numberWithFloat:+0.2]; shake.duration = 0.1; shake.autoreverses = YES; //是否重復 shake.repeatCount = 3; [itemView.iconImageView.layer addAnimation:shake forKey:@"imageView"];
以上這篇iOS動畫-定時對UIView進行翻轉和抖動的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。