美文网首页
OPBSheetTestView

OPBSheetTestView

作者: 洲洲哥 | 来源:发表于2025-03-04 15:52 被阅读0次

    //
    // OPBSheetTestView.swift
    // OPBHomeKit
    //
    // Created by zz on 5.3.25.
    //

    import UIKit
    import OPBUtils

    class OPBSheetTestView: UIView {

    override init(frame: CGRect) {
        super.init(frame: .zero)
        self.backgroundColor = UIColor.blackColorAlpha35
        
        self.addSubview(self.containerView)
        self.containerView.addSubview(self.noticeTitle)
        containerView.addSubview(bottomView)
        
        setupLayouts()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    public func show()  {
        self.setNeedsLayout()
        self.layoutIfNeeded()
        
        self.dismiss()
        let delegate:UIApplicationDelegate = UIApplication.shared.delegate!
        delegate.window??.addSubview(self)
        self.frame = CGRect(x: 0, y: 0, width: MainScreenWidth, height: MainScreenHeight)
    }
    
    public func dismiss() {
        self.removeFromSuperview()
    }
    
    
    lazy var containerView: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    
    lazy var noticeTitle: UILabel = {
        let lab = UILabel()
        lab.text = "Note"
        lab.textColor = UIColor.blackColorAlpha45
        lab.font = UIFont.opRegFont(fontSize: 14)
        lab.backgroundColor = .red
        return lab
    }()
    
    
    lazy var bottomView: UIView = {
        let view = UIView()
        view.backgroundColor = .green
        return view
    }()
    
    func setupLayouts() {
        self.containerView.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.bottom.equalToSuperview()
        }
        
        noticeTitle.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(100)
            make.height.equalTo(50)
            make.leading.trailing.equalToSuperview()
            
        }
        
        bottomView.snp.makeConstraints { make in
            make.top.equalTo(noticeTitle.snp.bottom).offset(100)
            make.height.equalTo(50)
            make.leading.trailing.equalToSuperview()
            make.bottom.equalToSuperview().offset(-100)
        }
    }
    
    
    public override func layoutSubviews() {
        super.layoutSubviews()
    
        
        
        
        
        
        DispatchQueue.main.async {
            self.containerView.roundCorners(corners: [.topLeft,.topRight], radius: 8)
        }
    }
    

    }

    相关文章

      网友评论

          本文标题:OPBSheetTestView

          本文链接:https://www.haomeiwen.com/subject/pgvhmjtx.html