zoukankan      html  css  js  c++  java
  • iOS 停止UIView的block动画

    iOS停止UIView的block动画的方法

    动画执行如下:

    UIView.animateWithDuration(animationDuringTime, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: { [weak self]() -> Void in
                        // do animation
                        animateView?.contentOffset.y = 0
                    }, completion: { [weak self](finished: Bool) -> Void in
                            NSLog("completion")
                    })                    
    

      

    如果在动画过程中突然想停止动画,需要执行如下方法

    // 这里的 animateView 要为 UIView block animation中进行动画效果的view
    animateView.layer.removeAllAnimations()
    

      

    方法执行之后,会UIView block动画会立刻进入completion流程,传入的 finished 值为 false, 可以在代码中通过判断 finished 为 true 或者 false 来区分动画是正常完成还是被停止的。

    UIView.animateWithDuration(animationDuringTime, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: { [weak self]() -> Void in
                        // do animation
                        animateView?.contentOffset.y = 0
                    }, completion: { [weak self](finished: Bool) -> Void in
                            if !finished{
                                NSLog("animation stop")
                            }else{
                                NSLog("completion")
                            }    
                    })   
    

      

      

      

  • 相关阅读:
    css 如何让背景图片拉伸填充避免重复显示
    CDHtmlDialog 基本使用
    RES协议
    Sata win7 热插拔(AHCI)
    __argc和__argv变量
    MFC进度条刷新处理
    SVN强制注释
    自动build服务器 CruiseControl.NET
    opencv Mat 像素操作
    std::string 用法
  • 原文地址:https://www.cnblogs.com/FranZhou/p/5128053.html
Copyright © 2011-2022 走看看