0

I want to put a gif as a background, I get it but the background takes time to appear. this is my code

in viewdidload I have this

override func viewDidLoad()
{
    super.viewDidLoad()
    DispatchQueue.main.async {
        let filePath = Bundle.main.path(forResource: "4", ofType: "gif")
        let gif = NSData(contentsOfFile: filePath!)

        let webViewBG = UIWebView(frame: self.view.frame)
        webViewBG.load(gif! as Data, mimeType: "image/gif", textEncodingName: "utf-8", baseURL: NSURL() as URL)
        webViewBG.isUserInteractionEnabled = false
        self.view.insertSubview(webViewBG, at: 0)
     }
}

I also had the idea of putting the code in viewwillappear but the background is slow to appear.

how i can fix it? any suggestions?

Andres Gomez
  • 458
  • 3
  • 12

0 Answers0