22Bottom sheets for iOS
33
44Minimum requirement:
5- ![ iOSVersion] ( https://img.shields.io/badge/iOS-10.3 -green.svg )
5+ ![ iOSVersion] ( https://img.shields.io/badge/iOS-9 -green.svg )
66![ SwiftVersion] ( https://img.shields.io/badge/Swift-4.2-green.svg )
77![ XcodeVersion] ( https://img.shields.io/badge/Xcode-10-green.svg )
88
9- ![ Demo] ( https://raw.githubusercontent.com/gordontucker/FittedSheets/master/fullDemo.gif )
10-
119## About
1210This project is to enable easily presenting view controllers in a bottom sheet that supports scrollviews and multiple sizes. Contributions and feedback are very welcome.
1311
1412The bottom sheet tries to be smart about the height it takes. If the view controller is smaller than the sizes specified, it will only grow as large as the intrensic height of the presented view controller. If it is larger, it will stop at each height specified in the initializer or setSizes function.
1513
14+ | Default Settings | Extended Background | Color Tinted | Navigation Controller |
15+ | :-:| :-:| :-:| :-:|
16+ | ![ Default Options] ( ss_default_options.png ) | ![ Extend Background Behind Bar] ( ss_extend_background.png ) | ![ Color Tinting] ( ss_colors.png ) | ![ Color Tinting] ( ss_navigation.png ) |
17+
1618## Usage
1719Using a bottom sheet is simple.
1820
@@ -25,7 +27,8 @@ let controller = MyViewController()
2527
2628let sheetController = SheetViewController (controller : controller)
2729
28- self .present (sheetController, animated : false , completion : nil ) // It is important to set animated to false or it behaves weird currently
30+ // It is important to set animated to false or it behaves weird currently
31+ self .present (sheetController, animated : false , completion : nil )
2932```
3033
3134** Customizing settings**
@@ -34,9 +37,26 @@ self.present(sheetController, animated: false, completion: nil) // It is importa
3437let controller = MyViewController ()
3538
3639let sheetController = SheetViewController (controller : controller, sizes : [.fixed (100 ), .fixed (200 ), .halfScreen , .fullScreen ])
40+
41+ // Adjust how the bottom safe area is handled on iPhone X screens
3742sheetController.blurBottomSafeArea = false
3843sheetController.adjustForBottomSafeArea = true
3944
45+ // Turn off rounded corners
46+ sheetController.roundTopCorners = false
47+
48+ // Disable the dismiss on background tap functionality
49+ sheetController.dismissOnBackgroundTap = false
50+
51+ // Extend the background behind the pull bar instead of having it transparent
52+ sheetController.extendBackgroundBehindHandle = true
53+
54+ // Change the overlay color
55+ sheetController.overlayColor = UIColor.red
56+
57+ // Change the handle color
58+ sheetController.handleColor = UIColor.orange
59+
4060self .present (controller, animated : false , completion : nil )
4161```
4262
@@ -54,29 +74,6 @@ self.present(sheet, animated: false, completion: nil)
5474
5575## Settings
5676
57- ``` swift
58- /// Determines if we should inset the view controller to account for the bottom safe area.
59- /// If your view controller already handles this, leave it false (the default)
60- /// If your view controller does *not* handle this, set it to true
61- var adjustForBottomSafeArea: Bool = false
62- ```
63-
64- ``` swift
65- /// Determines if we blur the contents under the bottom safe area (if there is a safe area)
66- /// The default value is true
67- var blurBottomSafeArea: Bool = true
68- ```
69-
70- ``` swift
71- /// The color of the overlay above the sheet.
72- var overlayColor: UIColor = UIColor (white : 0 , alpha : 0.7 )
73- ```
74-
75- ``` swift
76- /// Sets the heights the sheets will try to stick to. It will not resize the current size, but will affect all future resizing of the sheet.
77- func setSizes (_ sizes : [SheetSize])
78- ```
79-
8077``` swift
8178/// This should be called by any child view controller that expects the sheet to use be able to expand/collapse when the scroll view is at the top.
8279func handleScrollView (_ scrollView : UIScrollView)
@@ -88,7 +85,7 @@ There is an extension on UIViewController that gives you a `sheetViewController`
8885override func viewDidLoad () {
8986 super .viewDidLoad ()
9087
91- self .sheetViewController ? .handleScrollView (self .scrollView ) // or tableView/collectionView/etc
88+ self .sheetViewController ! .handleScrollView (self .scrollView ) // or tableView/collectionView/etc
9289}
9390```
9491
@@ -100,6 +97,12 @@ Add this to your podfile to add FittedSheets to your project.
10097pod 'FittedSheets'
10198```
10299
100+ ## TODO
101+
102+ * Add support for carthage
103+ * Add bounce effect when opening/closing
104+ * Support interacting with the background while the sheet is open
105+
103106## License
104107FittedSheets uses the MIT License:
105108
0 commit comments