1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // PQStuckPointLoadingView.swift
- // PQSpeed
- //
- // Created by SanW on 2021/5/24.
- // Copyright © 2021 BytesFlow. All rights reserved.
- //
- import Kingfisher
- import UIKit
- import BFCommonKit
- class PQStuckPointLoadingView: UIView {
- var cancelHandle: ((_ sender: UIButton) -> Void)?
- /// 同步进度显示
- lazy var loadingView: UIImageView = {
- let loadingView = UIImageView()
- loadingView.tintColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
- let data = try? Data(contentsOf: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
- if data != nil {
- PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { _, images, duration in
- loadingView.displayGIF(data: nil, images: images, repeatCount: .max, duration: duration ?? 2)
- }
- }
- return loadingView
- }()
- lazy var navBarLeftBtn: UIButton = {
- let navBarLeftBtn = UIButton(type: .custom)
- navBarLeftBtn.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
- navBarLeftBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
- navBarLeftBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
- navBarLeftBtn.tintColor = PQBFConfig.shared.styleTitleColor
- navBarLeftBtn.setImage(UIImage().BF_Image(named: "icon_detail_back").withRenderingMode(.alwaysTemplate), for: .normal)
- navBarLeftBtn.addTarget(self, action: #selector(cancelDownload(sender:)), for: .touchUpInside)
- return navBarLeftBtn
- }()
- override init(frame: CGRect) {
- super.init(frame: frame)
- backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.5)
- addSubViews()
- addLayout()
-
- }
- required init?(coder _: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- override func layoutSubviews() {
- super.layoutSubviews()
- }
- func addSubViews() {
- addSubview(loadingView)
- addSubview(navBarLeftBtn)
- }
- func addLayout() {
- loadingView.snp.makeConstraints { make in
- make.center.equalToSuperview()
- make.width.height.equalTo(cDefaultMargin * 10)
- }
- }
- /// 移除视图
- /// - Returns: <#description#>
- func removeMarskView() {
- removeFromSuperview()
- }
- @objc func cancelDownload(sender: UIButton) {
- if cancelHandle != nil {
- cancelHandle!(sender)
- removeMarskView()
- }
- }
- deinit {
- BFLog(message: "销毁加载中视图")
- }
- }
|