360旋转图片,常用于展示正在请求网络中


//    -(void)rotate360DegreeWithImageView {
//    
//    CABasicAnimation * rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; //让其在z轴旋转

//    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];//旋转角度
//    rotationAnimation.duration = 2; //旋转周期
//    rotationAnimation.cumulative = YES;//旋转累加角度



//    rotationAnimation.repeatCount = 100000;//旋转次数
//    [self.imageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
//    }


    func rotate360DegreeWithImageView()  {

        let rotationAnimation:CABasicAnimation = CABasicAnimation.init(keyPath: "transform.rotation.z");

        rotationAnimation.toValue = NSNumber.init(value: Double.pi * 2.0);
        rotationAnimation.duration = 2;
        rotationAnimation.isCumulative = true;

        rotationAnimation.repeatCount = 100000
        self.changeIpBtn.imageView?.layer.add(rotationAnimation, forKey: "rotationAnimation");





    }
//    
//    
//    -(void)stopRotate {
//    [self.imageView.layer removeAllAnimations];
//    }

    func stopRotate() {
        self.changeIpBtn.imageView?.layer.removeAllAnimations();
    }
发布了456 篇原创文章 · 获赞 310 · 访问量 40万+

猜你喜欢

转载自blog.csdn.net/u011018979/article/details/78151315