Skip to content

Commit f9eb359

Browse files
committed
Fixed a bug with how we were setting the handle color and updated readme
1 parent d002975 commit f9eb359

File tree

8 files changed

+40
-38
lines changed

8 files changed

+40
-38
lines changed

FittedSheets.podspec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "FittedSheets",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"summary": "A bottom sheets implementation for iOS apps.",
55
"description": "iOS doesn't have a good way to use bottom sheets natively, so this is to bridge the gap with a decent looking implementation.",
66
"homepage": "https://github.com/gordontucker/FittedSheets",
@@ -10,7 +10,7 @@
1010
},
1111
"source": {
1212
"git": "https://github.com/gordontucker/FittedSheets.git",
13-
"tag": "1.2.0"
13+
"tag": "1.2.1"
1414
},
1515
"platforms": {
1616
"ios": "9.0"

FittedSheets/ColorExample/ColorExampleViewController.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ class ColorExampleViewController: UIViewController {
1212

1313
override func viewDidLoad() {
1414
super.viewDidLoad()
15-
}
16-
17-
override func viewWillAppear(_ animated: Bool) {
1815
self.sheetViewController?.handleColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.8)
1916
self.sheetViewController?.overlayColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.3)
2017
}

FittedSheetsPod/SheetViewController.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ public class SheetViewController: UIViewController {
1515
/// The view that can be pulled to resize a sheeet. This includes the background. To change the color of the bar, use `handleView` instead
1616
public let pullBarView = UIView()
1717
public let handleView = UIView()
18-
public var handleColor: UIColor? {
19-
get { return handleView.backgroundColor }
20-
set { handleView.backgroundColor = newValue }
18+
public var handleColor: UIColor = UIColor(white: 0.868, alpha: 1) {
19+
didSet {
20+
self.handleView.backgroundColor = self.handleColor
21+
}
2122
}
2223

2324
/// If true, tapping on the overlay above the sheet will dismiss the sheet view controller
@@ -42,6 +43,7 @@ public class SheetViewController: UIViewController {
4243
/// Turn rounding on or off for the top corners. Only available for iOS 11 and above
4344
public var roundTopCorners: Bool = true {
4445
didSet {
46+
guard isViewLoaded else { return }
4547
self.updateRoundedCorners()
4648
}
4749
}
@@ -108,7 +110,7 @@ public class SheetViewController: UIViewController {
108110
fatalError("SheetViewController requires a child view controller")
109111
}
110112

111-
self.view.backgroundColor = UIColor.clear
113+
self.view.backgroundColor = self.overlayColor
112114
self.setUpContainerView()
113115
self.setUpDismissView()
114116

@@ -275,7 +277,7 @@ public class SheetViewController: UIViewController {
275277

276278
handleView.layer.cornerRadius = 3
277279
handleView.layer.masksToBounds = true
278-
handleView.backgroundColor = UIColor(white: 0.868, alpha: 1)
280+
handleView.backgroundColor = self.handleColor
279281
}
280282

281283
@objc func dismissTapped() {

README.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
Bottom sheets for iOS
33

44
Minimum 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
1210
This 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

1412
The 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
1719
Using a bottom sheet is simple.
1820

@@ -25,7 +27,8 @@ let controller = MyViewController()
2527

2628
let 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
3437
let controller = MyViewController()
3538

3639
let 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
3742
sheetController.blurBottomSafeArea = false
3843
sheetController.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+
4060
self.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.
8279
func handleScrollView(_ scrollView: UIScrollView)
@@ -88,7 +85,7 @@ There is an extension on UIViewController that gives you a `sheetViewController`
8885
override 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.
10097
pod '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
104107
FittedSheets uses the MIT License:
105108

ss_colors.png

68.9 KB
Loading

ss_default_options.png

53.2 KB
Loading

ss_extend_background.png

46.6 KB
Loading

ss_navigation.png

27.4 KB
Loading

0 commit comments

Comments
 (0)