例如封裝請(qǐng)求時(shí),自定義一個(gè)圖片旋轉(zhuǎn)的提示框,
代碼:
CABasicAnimation* rotationAnimation;
//繞哪個(gè)軸,那么就改成什么:這里是繞z軸 ---> transform.rotation.z
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
//旋轉(zhuǎn)角度
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI];
//每次旋轉(zhuǎn)的時(shí)間(單位秒)
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.removedOnCompletion = NO;
//重復(fù)旋轉(zhuǎn)的次數(shù),如果你想要無(wú)數(shù)次,那么設(shè)置成MAXFLOAT
rotationAnimation.repeatCount = MAXFLOAT;
[self.imageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

image.png
中心的圖片會(huì)一直旋轉(zhuǎn)