UIView.animateWithDuration 沒有動畫過渡效果直接跳到最后


當我在viewDidLoad()方法內添加以下代碼的時候發現程序運行時不會有動畫過度效果,而是直接跳到了最后。

        let x = (self.view.bounds.size.width - 268) / 2
        scanImage.frame = CGRectMake(x, 106, 268, 2)
        scanImage.contentMode = UIViewContentMode.ScaleAspectFill
        self.view.addSubview(scanImage)
        
        UIView.animateWithDuration(2, delay: 0, options: UIViewAnimationOptions.Repeat, animations: { () -> Void in
            self.scanImage.frame = CGRectMake(x,372, 268, 2)
        }, completion: nil)

 通過度娘后有網友說要把該代碼塊放到viewDidAppear(animated: Bool)方法內,試以一下果然有動畫效果了。這到底是為什么啊?who can tell me why?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM