@@ -23,22 +23,12 @@ final class DemoViewController: UIViewController {
23
23
private func setup( ) {
24
24
view. backgroundColor = . white
25
25
26
- let buttonA = UIButton ( type: . system)
27
- buttonA. setTitle ( " Navigation View Controller " , for: . normal)
28
- buttonA. titleLabel? . font = . systemFont( ofSize: 18 )
29
- buttonA. addTarget ( self , action: #selector( presentNavigationViewController) , for: . touchUpInside)
30
-
31
- let buttonB = UIButton ( type: . system)
32
- buttonB. setTitle ( " View Controller " , for: . normal)
33
- buttonB. titleLabel? . font = . systemFont( ofSize: 18 )
34
- buttonB. addTarget ( self , action: #selector( presentViewController) , for: . touchUpInside)
35
-
36
- let buttonC = UIButton ( type: . system)
37
- buttonC. setTitle ( " View " , for: . normal)
38
- buttonC. titleLabel? . font = . systemFont( ofSize: 18 )
39
- buttonC. addTarget ( self , action: #selector( presentView) , for: . touchUpInside)
40
-
41
- let stackView = UIStackView ( arrangedSubviews: [ buttonA, buttonB, buttonC] )
26
+ let stackView = UIStackView ( arrangedSubviews: [
27
+ createButton ( title: " Navigation View Controller " , selector: #selector( presentNavigationViewController) ) ,
28
+ createButton ( title: " View Controller " , selector: #selector( presentViewController) ) ,
29
+ createButton ( title: " View " , selector: #selector( presentView) ) ,
30
+ createButton ( title: " Automatic dismiss after 0.05s " , selector: #selector( presentAutomaticDismiss) ) ,
31
+ ] )
42
32
stackView. translatesAutoresizingMaskIntoConstraints = false
43
33
stackView. axis = . vertical
44
34
@@ -50,6 +40,14 @@ final class DemoViewController: UIViewController {
50
40
] )
51
41
}
52
42
43
+ private func createButton( title: String , selector: Selector ) -> UIButton {
44
+ let button = UIButton ( type: . system)
45
+ button. setTitle ( title, for: . normal)
46
+ button. titleLabel? . font = . systemFont( ofSize: 18 )
47
+ button. addTarget ( self , action: selector, for: . touchUpInside)
48
+ return button
49
+ }
50
+
53
51
// MARK: - Presentation logic
54
52
55
53
@objc private func presentNavigationViewController( ) {
@@ -62,6 +60,20 @@ final class DemoViewController: UIViewController {
62
60
present ( navigationController, animated: true )
63
61
}
64
62
63
+ @objc private func presentAutomaticDismiss( ) {
64
+ let viewController = ViewController ( withNavigationButton: true , contentHeight: 400 )
65
+ viewController. title = " Step 1 "
66
+
67
+ let navigationController = BottomSheetNavigationController ( rootViewController: viewController)
68
+ navigationController. navigationBar. isTranslucent = false
69
+
70
+ present ( navigationController, animated: true )
71
+
72
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.05 , execute: { [ weak navigationController] in
73
+ navigationController? . dismiss ( animated: true )
74
+ } )
75
+ }
76
+
65
77
// MARK: - Presentation logic
66
78
67
79
@objc private func presentViewController( ) {
0 commit comments