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