//
// 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.
}
}
Creare un controller di vista, come illustrato nel codice precedente. Nota: - durante la creazione di una visualizzazione di immagini nella story board, impostare la classe di visualizzazione dell'immagine come FLanimatedImageView.
Funzionerà.
Qui Loader.gif è l'immagine GIF.
fonte
2017-09-29 03:49:22
è possibile utilizzare questa libreria https://github.com/Flipboard/FLAnimatedImage –
caricare l'immagine GIF in Swift: https://iosdevcenters.blogspot.com/2016/08/load-gif-image-in-swift_22. html –