//
// ViewController.swift
// Loader
//
// Created by Pawan Kumar on 28/09/17.
// Copyright © 2017 Pawan Kumar. All rights reserved.
//
import UIKit
import FLAnimatedImage
class ViewController: UIViewController {
@IBOutlet weak var animatedImageView: FLAnimatedImageView!
// @IBOutlet weak var checkImageView: FLAnimatedImageView!
override func viewDidLoad() {
super.viewDidLoad()
let url = Bundle.main.path(forResource: "Loader", ofType: "gif")
print(url!)
let data=NSData(contentsOfFile: url!)
//print(data)
let fff=FLAnimatedImage(gifData: data as Data?)
let imageView=FLAnimatedImageView()
imageView.animatedImage=fff
//
// imageView.frame=CGRect(x: animatedImageView.frame.minX, y: animatedImageView.frame.minY, width: animatedImageView.frame.width, height: animatedImageView.frame.height)
imageView.frame=CGRect(x: animatedImageView.frame.minX, y: animatedImageView.frame.minY, width: animatedImageView.frame.width, height: animatedImageView.frame.height)
print(imageView.currentFrameIndex)
imageView.clipsToBounds=true
self.view.addSubview(imageView)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
einen View-Controller erstellen, wie im oben angezeigten Code ein. Hinweis: - Legen Sie beim Erstellen einer Bildansicht im Storyboard die Klasse der Bildansicht als FLanimatedImageView fest.
Es wird funktionieren.
Hier Loader.gif ist das GIF-Bild.
Sie können diese Bibliothek verwenden https://github.com/Flipboard/FLAnimatedImage –
laden Sie GIF-Bild in Swift: https://iosdevcenters.blogspot.com/2016/08/load-gif-image-in-swift_22. html –