Skip to content

Commit e93363b

Browse files
committed
add pop
1 parent 9311d49 commit e93363b

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// PopupController.swift
3+
// HTComponents
4+
//
5+
// Created by mac on 2021/6/10.
6+
//
7+
8+
import UIKit
9+
import SnapKit
10+
11+
@objc(HTPopupViewProtocol)
12+
public protocol PopupViewProtocol: NSObjectProtocol {
13+
weak var popupControllerDelegate: PopupControllerProtocol? { set get }
14+
}
15+
16+
@objc(HTPopupControllerProtocol)
17+
public protocol PopupControllerProtocol: NSObjectProtocol {
18+
func dismiss()
19+
}
20+
21+
@objc(HTPopupController)
22+
@objcMembers
23+
open class PopupController: UIViewController, PopupControllerProtocol {
24+
25+
public let customView: UIView & PopupViewProtocol
26+
27+
public init(_ customView: UIView & PopupViewProtocol) {
28+
self.customView = customView
29+
super.init(nibName: nil, bundle: nil)
30+
self.customView.popupControllerDelegate = self
31+
modalPresentationStyle = .overFullScreen
32+
modalTransitionStyle = .crossDissolve
33+
}
34+
35+
required public init?(coder: NSCoder) {
36+
fatalError("init(coder:) has not been implemented")
37+
}
38+
39+
open override func viewDidLoad() {
40+
super.viewDidLoad()
41+
42+
view.backgroundColor = UIColor.black.withAlphaComponent(0.3)
43+
44+
view.addSubview(self.customView)
45+
self.customView.snp.makeConstraints { make in
46+
make.center.equalToSuperview()
47+
make.width.height.lessThanOrEqualToSuperview()
48+
}
49+
50+
}
51+
52+
public func dismiss() {
53+
dismiss(animated: true, completion: nil)
54+
}
55+
56+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// PopupView.swift
3+
// HTComponents
4+
//
5+
// Created by mac on 2021/6/10.
6+
//
7+
8+
import UIKit
9+
10+
@objc(HTPopupView)
11+
@objcMembers
12+
open class PopupView: UIView, PopupViewProtocol {
13+
14+
public weak var popupControllerDelegate: PopupControllerProtocol?
15+
16+
public override init(frame: CGRect) {
17+
super.init(frame: frame)
18+
}
19+
20+
required public init?(coder: NSCoder) {
21+
fatalError("init(coder:) has not been implemented")
22+
}
23+
24+
}

0 commit comments

Comments
 (0)