当我在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 没有动画过渡效果直接跳到最后的更多相关文章

  1. swift uiview弹出动画

    UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.3, initialSpringVelocity: 0.0, ...

  2. [UIView beginAnimations:context:]与[UIView animateWithDuration:animations:]值得注意的一个区别

    原文链接:http://longtimenoc.com/archives/uiview-beginanimationscontext%E4%B8%8Euiview-animatewithduratio ...

  3. iOS UIView简单缩放动画

    @interface ViewController () { UIView *animationView; UIButton *button; CGPoint animationPoint; } @e ...

  4. xcode UIView常用方法属性动画

    常见属性: @property(nonatomic,readonly) UIView *superview; 获得自己的父控件对象 @property(nonatomic,readonly,copy) ...

  5. UIView animateWithDuration 使用详解

    在ios4.0及以后鼓励使用animateWithDuration方法来实现动画效果.当然,以往的begin/commit的方法依然使用,下面详细解释一下animateWithDuration的使用方 ...

  6. iOS开发——动画编程Swift篇&(二)UIView转场动画

    UIView转场动画 // MARK: - UIView动画-过度动画 var redView:UIView? var blueView:UIView? // enum UIViewAnimation ...

  7. UIView转场动画属性设置

    常规动画属性设置(可以同时选择多个进行设置) UIViewAnimationOptionLayoutSubviews:动画过程中保证子视图跟随运动. UIViewAnimationOptionAllo ...

  8. UIView 弹出动画

    // 展开动画 - (void)beginAnimations { CGContextRef context = UIGraphicsGetCurrentContext(); [UIView begi ...

  9. CSS3动画--过渡效果

    CSS3动画--过渡效果 transition                               设置四个过渡属性 transition-property          过渡的名称 tr ...

随机推荐

  1. 关于PATH_INFO

    nginx支持PATH_INFO? 想让nginx支持PATH_INFO,首先需要知道什么是pathinfo,为什么要用pathinfo? pathinfo不是nginx的功能,pathinfo是ph ...

  2. Django本地开发,debug模式引用静态文件

    debug为true ,不用设置static_root debug 为false ,设置static_root STATIC_ROOT = ( os.path.join(BASE_DIR, 'stat ...

  3. testNG 学习笔记 Day 3 常用的断言

    TestNG中最常用的一个断言类是Assert.java,里面有多个静态方法,这个类我们习惯叫硬断言.对应的还有一个软断言的类,叫SoftAssert.java,这个类是需要创建实例对象,才能调用相关 ...

  4. [ios]iOS8 定位

    参考:http://www.2cto.com/kf/201410/342392.html http://blog.csdn.net/yongyinmg/article/details/39521523 ...

  5. shell 特殊变量详解

    $0 获取当前执行脚本的名称,包括路径 [root@centos test]# cat test.sh echo $0 [root@VM_102_244_centos test]# bash test ...

  6. 页面资源缓存 html css js

    html <meta http-equiv="Expires" content="0"><meta http-equiv="Prag ...

  7. php 邮件发送利器 PHPMailer

    php 自带的邮件发送函数已经弱到不能用了. PHPMailer非常的强大. 绝对是php里必须使用的程序. 下载地址: https://github.com/Synchro/PHPMailer 只要 ...

  8. 一个Java例子,解释清楚注解的作用

    原文出处:码农登陆 写在前面 今天聊的是注解,但其实单纯说注解,注解本身没有任何的作用.简单说和注释没啥区别,而它有作用的原因是:注解解释类,也就是相关对代码进行解释的特定类.一般这些类使用反射是可以 ...

  9. Android Webview 和Javascript交互,实现Android和JavaScript相互调用

    在Android的开发过程中.遇到一个新需求.那就是让Java代码和Javascript代码进行交互.在IOS中实现起来很麻烦.而在Android中相对来说容易多了.Android对这种交互进行了很好 ...

  10. 『PyTorch』第五弹_深入理解autograd_下:函数扩展&高阶导数

    一.封装新的PyTorch函数 继承Function类 forward:输入Variable->中间计算Tensor->输出Variable backward:均使用Variable 线性 ...