OPBSheetTestView

//
// 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)
    }
}

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容