关于UIimageView 动画 内存处理办法

GANWEI

GANWEI

发表于 2016-07-23 20:30:18
关于UIimageView 动画 内存处理办法
    func  creatRotatingAnimation(){
        
        animationImage = UIImageView()
        
        self.view.addSubview(animationImage)
        
        animationImage.snp_makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.centerY.equalToSuperview()
            make.height.equalTo(UIScreen.mainScreen().bounds.size.width/1.5)
        }

       myAnimatedTimer  = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: #selector(self.creatAnimationImage), userInfo: nil, repeats: true)
        
    }

    func creatAnimationImage(){
    
        if indexInt > 17 {
        
            indexInt = 1
            
        }
        
    let nameImage = "TS_playAnimation" + String.init(indexInt) + "@3x"
        
    indexInt = indexInt + 1
        
    let path = NSBundle.mainBundle().pathForResource(nameImage, ofType: "png")
        
    animationImage.image = UIImage.init(contentsOfFile: path!)!
        
    }
    
    override func viewWillDisappear(animated: Bool) {
        super.viewDidDisappear(animated)
        
        myAnimatedTimer.invalidate()
        myAnimatedTimer = nil
        animationImage.removeFromSuperview()
        
    }




                            
用户评论
开源开发学习小组列表