Files
suixinkan_uikit/suixinkan/UI/Loading/GlobalLoadingOverlayView.swift

54 lines
1.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// GlobalLoadingOverlayView.swift
// suixinkan
//
import SnapKit
import UIKit
/// Loading Android `LoadingScrim`
final class GlobalLoadingOverlayView: UIView {
private let cardView = UIView()
private let loadingView = LottieLoadingView()
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.black.withAlphaComponent(0.2)
isUserInteractionEnabled = true
cardView.backgroundColor = .white
cardView.layer.cornerRadius = 15
cardView.clipsToBounds = true
addSubview(cardView)
cardView.addSubview(loadingView)
cardView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(100)
}
loadingView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(80)
}
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
///
func present() {
isHidden = false
loadingView.startAnimating()
}
///
func dismiss() {
loadingView.stopAnimating()
isHidden = true
}
}