FFJLoadButton 是一个使用 Swift 编写的 UIButton 子类,它提供了一个简单的 UI 加载动画功能。
FFJLoadButton 主要提供两种方法
startLoad()
endLoad(_:)
示例
self.loadButton.startLoad()
let imageURL = NSURL.init(string: "https://fakeurl.com")
NSURLSession.sharedSession().dataTaskWithURL(imageURL!) { (imageData, response, error) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if let _ = error {
self.imageView.image = nil
self.loadButton.endLoad(false)
return
}
self.imageView.image = UIImage.init(data: imageData!)
self.loadButton.endLoad(true)
})
}.resume()
查看演示了解更多详情。
只需将 FFJLoadButton.swift 拖动到你的项目中
iOS 8.0+
FFJLoadButton 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。