美文网首页
iOS-图片旋转

iOS-图片旋转

作者: Freedom_fly | 来源:发表于2017-10-13 15:02 被阅读48次

例如封装请求时,自定义一个图片旋转的提示框,
代码:

    CABasicAnimation* rotationAnimation;
    //绕哪个轴,那么就改成什么:这里是绕z轴 ---> transform.rotation.z
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    //旋转角度
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI];
    //每次旋转的时间(单位秒)
    rotationAnimation.duration = 1;
    rotationAnimation.cumulative = YES;
    rotationAnimation.removedOnCompletion = NO;
    //重复旋转的次数,如果你想要无数次,那么设置成MAXFLOAT
    rotationAnimation.repeatCount = MAXFLOAT;
    [self.imageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
image.png

中心的图片会一直旋转

相关文章

网友评论

      本文标题:iOS-图片旋转

      本文链接:https://www.haomeiwen.com/subject/ntpzyxtx.html