簡體   English   中英

無法在我的應用程序中使用 Gifu Pod “GIF 不出現”

[英]Cannot use Gifu Pod in my app “GIF doesn't appear”

我一直在我的代碼中使用Gifu pod,但它不能正常工作,gif 根本沒有出現。

啟動屏幕圖像:

在此處輸入圖像描述

啟動屏幕代碼:

import UIKit
import Gifu

class LaunchScreenViewController: UIViewController {


@IBOutlet weak var imageViewGIF: GIFImageView!

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.navigationBar.isHidden = true
    animate()
    
}


func animate() {
    imageViewGIF.prepareForAnimation(withGIFNamed: "animatedTick.gif", loopCount: 1)
    self.imageViewGIF.animate(withGIFNamed: "mugen")
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
        self.imageViewGIF.startAnimatingGIF()
        DispatchQueue.global().asyncAfter(deadline: .now() + 0.5 + self.imageViewGIF.gifLoopDuration, execute: {
            
        })
        let loginViewController = self.storyboard!.instantiateViewController(identifier: "LoginViewController")
        self.navigationController?.pushViewController(loginViewController, animated: true)
    }
    
}
}

UIImageViewExtension.swift代碼

import UIKit
import Gifu

extension UIImageView: GIFAnimatable {
  private struct AssociatedKeys {
    static var AnimatorKey = "gifu.animator.key"
  }

  override open func display(_ layer: CALayer) {
    updateImageIfNeeded()
  }

  public var animator: Animator? {
    get {
      guard let animator = objc_getAssociatedObject(self, &AssociatedKeys.AnimatorKey) as? Animator else {
        let animator = Animator(withDelegate: self)
        self.animator = animator
        return animator
      }

      return animator
    }

    set {
      objc_setAssociatedObject(self, &AssociatedKeys.AnimatorKey, newValue as Animator?, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
    }
  }
}

請注意,主 LaunchScreen 文件仍然相同,我沒有更改任何內容,我只是嘗試創建自定義文件。

嘗試僅使用self.imageViewGIF.animate(withGIFNamed: "mugen")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM