【问题标题】:Using LOTAnimationView with Auto Layout in Storyboard在 Storyboard 中使用 LOTAnimationView 和自动布局
【发布时间】:2018-09-16 20:49:46
【问题描述】:

有没有办法在自动布局中使用LOTAnimationView(Lottie 框​​架)?我尝试在我的故事板中将UIView 的类设置为LOTAnimationView,但得到nil IB 出口..

【问题讨论】:

    标签: ios swift autolayout uistoryboard lottie


    【解决方案1】:

    在最新的 Lottie 版本中应该这样设置:

    并在此处设置动画名称:

    这里是示例代码:

    import UIKit
    import Lottie
    
    class ViewController: UIViewController {
    
        @IBOutlet weak var animationView: AnimationView!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            animationView.play()
    
        }
    }
    

    【讨论】:

      【解决方案2】:

      采取LOTAnimatedControl的出口。

      将您的 JSON 文件分配给 LOTAnimationView

      lot.animationView.setAnimation(named: "checked_done_")
      

      完整示例:

      import UIKit
      import Lottie
      
      class ViewController: UIViewController {
          @IBOutlet weak var lot: LOTAnimatedControl!
          override func viewDidLoad() {
              super.viewDidLoad()
              lot.animationView.setAnimation(named: "youranimationjsonfile")
              lot.animationView.play()
          }
      }
      

      希望这会对你有所帮助。

      【讨论】:

        【解决方案3】:

        使用Ashish Kakkad 的评论更新最新的 Lottie 版本。

        更改类名AnimationView 而不是LOTAnimatedControl

        然后从 Interface Builder 中设置属性 animationName

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-01-30
          • 2016-10-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多