码迷,mamicode.com
首页 > 其他好文 > 详细

UIView.animateWithDuration 没有动画过渡效果直接跳到最后

时间:2015-08-20 00:59:23      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:

当我在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?

UIView.animateWithDuration 没有动画过渡效果直接跳到最后

标签:

原文地址:http://www.cnblogs.com/foxting/p/4743684.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!