jsdw_ios/QuickLocation/UIKit/Pop/DLSheetPopVC.swift

117 lines
3.1 KiB
Swift

//
// DLSheetPopVC.swift
// dinoGo
//
// Created by on 2022/12/2.
// Copyright © 2022 dino. All rights reserved.
//
import Foundation
import UIKit
public class DLSheetPopVC: DLCustomPopVC {
lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 16, weight: .medium)
label.textColor = UIColor(hexStr: "#0E0E0E")
return label
}()
lazy var contentLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 13, weight: .regular)
label.textColor = UIColor(hexStr: "#0E0E0E")
label.numberOfLines = 0
return label
}()
lazy var closeBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setImage(UIImage(named: "Common/close")?.image(scaleSize: CGSize(width: 12, height: 12)), for: .normal)
btn.contentEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
btn.addTouchBlock { [weak self] _ in
self?.dismiss(animated: true)
}
return btn
}()
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hexStr: "#F4F4F4")
return view
}()
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
popStyle = .bottom
bottomCornerRadius = 10
dimmingClick = false
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func viewDidLoad() {
super.viewDidLoad()
setupSubViews()
setupLayout()
}
}
// MARK: - UI
private extension DLSheetPopVC {
func setupSubViews() {
contentView.addSubview(titleLabel)
contentView.addSubview(closeBtn)
contentView.addSubview(lineView)
contentView.addSubview(contentLabel)
}
func setupLayout() {
titleLabel.layoutChain
.left(15, relation: .greaterThanOrEqual)
.top(15)
.centerX()
closeBtn.layoutChain
.centerY(titleLabel)
.right(6)
.size(CGSize(width: 28, height: 28))
.leftToRightOfView(titleLabel, offset: 10, relation: .greaterThanOrEqual)
lineView.layoutChain
.topToBottomOfView(titleLabel, offset: 15)
.left()
.right()
.height(0.5)
contentLabel.layoutChain
.topToBottomOfView(lineView, offset: 15)
.left(15)
.right(15)
.bottom(15, relation: .greaterThanOrEqual)
contentView.layoutChain
.height(kScreenHeight * 0.35, relation: .greaterThanOrEqual)
}
}
public extension UIViewController {
///
/// - Parameters:
/// - title:
/// - subTitle:
func showSheet(title: String, subTitle: String) {
let vc = DLSheetPopVC()
vc.titleLabel.text = title
vc.contentLabel.text = subTitle
present(vc, animated: true)
}
}