|
@@ -13,10 +13,25 @@ public class PQLoadingHUBView: UIView {
|
|
public var gifImages: [UIImage]?
|
|
public var gifImages: [UIImage]?
|
|
// gif播放时长
|
|
// gif播放时长
|
|
public var duration: Double?
|
|
public var duration: Double?
|
|
-
|
|
|
|
|
|
+ // 主题色
|
|
|
|
+ public var lodingColor: UIColor? {
|
|
|
|
+ didSet{
|
|
|
|
+ if lodingColor != nil {
|
|
|
|
+ loadingImage.tintColor = lodingColor ?? UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
|
|
|
|
+ let data = try? Data(contentsOf: URL(fileURLWithPath: Bundle.current(moduleName: "BFCommonKit")?.path(forResource: "stuckPoint_music_loading", ofType: ".gif") ?? ""))
|
|
|
|
+ if data != nil {
|
|
|
|
+ PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: lodingColor ?? UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { [weak self] _, images, duration in
|
|
|
|
+ self?.gifImages = images
|
|
|
|
+ self?.duration = duration
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public lazy var loadingImage: UIImageView = {
|
|
public lazy var loadingImage: UIImageView = {
|
|
let loadingImage = UIImageView()
|
|
let loadingImage = UIImageView()
|
|
- loadingImage.tintColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
|
|
|
|
|
|
+ loadingImage.tintColor = lodingColor ?? UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
|
|
return loadingImage
|
|
return loadingImage
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -26,7 +41,7 @@ public class PQLoadingHUBView: UIView {
|
|
isUserInteractionEnabled = false
|
|
isUserInteractionEnabled = false
|
|
let data = try? Data(contentsOf: URL(fileURLWithPath: Bundle.current(moduleName: "BFCommonKit")?.path(forResource: "stuckPoint_music_loading", ofType: ".gif") ?? ""))
|
|
let data = try? Data(contentsOf: URL(fileURLWithPath: Bundle.current(moduleName: "BFCommonKit")?.path(forResource: "stuckPoint_music_loading", ofType: ".gif") ?? ""))
|
|
if data != nil {
|
|
if data != nil {
|
|
- PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { [weak self] _, images, duration in
|
|
|
|
|
|
+ PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: lodingColor ?? UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { [weak self] _, images, duration in
|
|
self?.gifImages = images
|
|
self?.gifImages = images
|
|
self?.duration = duration
|
|
self?.duration = duration
|
|
}
|
|
}
|
|
@@ -66,12 +81,12 @@ public class PQLoadingHUB: NSObject {
|
|
public let viewTag = 11111
|
|
public let viewTag = 11111
|
|
public var isLoading: Bool = false
|
|
public var isLoading: Bool = false
|
|
|
|
|
|
- public func showHUB(isMode:Bool = false) {
|
|
|
|
|
|
+ public func showHUB(isMode:Bool = false,lodingColor:UIColor? = nil) {
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
let window = UIApplication.shared.keyWindow
|
|
let window = UIApplication.shared.keyWindow
|
|
if (window?.viewWithTag(self!.viewTag)) == nil {
|
|
if (window?.viewWithTag(self!.viewTag)) == nil {
|
|
let loadingHUB: PQLoadingHUBView = PQLoadingHUBView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
|
let loadingHUB: PQLoadingHUBView = PQLoadingHUBView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
|
-
|
|
|
|
|
|
+ loadingHUB.lodingColor = lodingColor
|
|
if(isMode){
|
|
if(isMode){
|
|
let backView = UIImageView.init(frame: window?.frame ?? .zero)
|
|
let backView = UIImageView.init(frame: window?.frame ?? .zero)
|
|
backView.backgroundColor = .clear
|
|
backView.backgroundColor = .clear
|
|
@@ -101,7 +116,7 @@ public class PQLoadingHUB: NSObject {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public func showHUB(superView: UIView, isVerticality: Bool = false) {
|
|
|
|
|
|
+ public func showHUB(superView: UIView, isVerticality: Bool = false,lodingColor:UIColor? = nil) {
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
if superView.viewWithTag(self!.viewTag) == nil {
|
|
if superView.viewWithTag(self!.viewTag) == nil {
|
|
let hubW: CGFloat = 100
|
|
let hubW: CGFloat = 100
|
|
@@ -110,6 +125,7 @@ public class PQLoadingHUB: NSObject {
|
|
let hubY: CGFloat = isVerticality ? ((supW - hubW) / 2) : ((supH - hubW) / 2)
|
|
let hubY: CGFloat = isVerticality ? ((supW - hubW) / 2) : ((supH - hubW) / 2)
|
|
let hubX: CGFloat = isVerticality ? ((supH - hubW) / 2) : ((supW - hubW) / 2)
|
|
let hubX: CGFloat = isVerticality ? ((supH - hubW) / 2) : ((supW - hubW) / 2)
|
|
let loadingHUB: PQLoadingHUBView = PQLoadingHUBView(frame: CGRect(x: hubX, y: hubY, width: 100, height: 100))
|
|
let loadingHUB: PQLoadingHUBView = PQLoadingHUBView(frame: CGRect(x: hubX, y: hubY, width: 100, height: 100))
|
|
|
|
+ loadingHUB.lodingColor = lodingColor
|
|
loadingHUB.tag = self!.viewTag
|
|
loadingHUB.tag = self!.viewTag
|
|
superView.addSubview(loadingHUB)
|
|
superView.addSubview(loadingHUB)
|
|
loadingHUB.loading()
|
|
loadingHUB.loading()
|