|
@@ -12,15 +12,10 @@ import UIKit
|
|
|
|
|
|
class BFLoadingView: UIView {
|
|
|
var cancelHandle: (() -> Void)?
|
|
|
-
|
|
|
- // gif每一帧图
|
|
|
- public var gifImages: [UIImage]?
|
|
|
- // gif播放时长
|
|
|
- public var duration: Double?
|
|
|
-
|
|
|
+
|
|
|
public lazy var loadingImage: UIImageView = {
|
|
|
let loadingImage = UIImageView()
|
|
|
- loadingImage.tintColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
|
|
|
+ loadingImage.image = imageInRecordScreenKit(by: "stuckPoint_edit_loading")
|
|
|
return loadingImage
|
|
|
}()
|
|
|
|
|
@@ -49,13 +44,6 @@ class BFLoadingView: UIView {
|
|
|
addSubview(closedBtn)
|
|
|
addSubview(titleL)
|
|
|
|
|
|
- let data = try? Data(contentsOf: URL(fileURLWithPath: currentBundle()!.path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
|
|
|
- if data != nil {
|
|
|
- PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)) { [weak self] _, images, duration in
|
|
|
- self?.gifImages = images
|
|
|
- self?.duration = duration
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
required init?(coder _: NSCoder) {
|
|
@@ -76,18 +64,26 @@ class BFLoadingView: UIView {
|
|
|
public func loadShow() {
|
|
|
|
|
|
isHidden = false
|
|
|
- loadingImage.displayGIF(data: nil, images: gifImages, repeatCount: .max, duration: duration ?? 2)
|
|
|
+ loadingImage.layer.removeAllAnimations()
|
|
|
+ loadingImage.isHidden = false
|
|
|
+ // 1.创建动画
|
|
|
+ let rotationAnim = CABasicAnimation(keyPath: "transform.rotation.z")
|
|
|
+ // 2.设置动画的属性
|
|
|
+ rotationAnim.fromValue = 0
|
|
|
+ rotationAnim.toValue = Double.pi * 2
|
|
|
+ rotationAnim.repeatCount = MAXFLOAT
|
|
|
+ rotationAnim.duration = 1
|
|
|
+ // 这个属性很重要 如果不设置当页面运行到后台再次进入该页面的时候 动画会停止
|
|
|
+ rotationAnim.isRemovedOnCompletion = false
|
|
|
+ // 3.将动画添加到layer中
|
|
|
+ loadingImage.layer.add(rotationAnim, forKey: nil)
|
|
|
}
|
|
|
-
|
|
|
- //启动动画
|
|
|
- public func startGIF(){
|
|
|
- loadingImage.displayGIF(data: nil, images: gifImages, repeatCount: .max, duration: duration ?? 2)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
public func removeLoading(){
|
|
|
isHidden = true
|
|
|
- loadingImage.removePlayGIF()
|
|
|
+
|
|
|
+ loadingImage.layer.removeAllAnimations()
|
|
|
+ loadingImage.isHidden = true
|
|
|
|
|
|
}
|
|
|
|