YYBottomSheet
Introduction
When you need to let users choose one of several or know informations by showing bottomSheet, you can use YYBottomSheet. Simple And Clear
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Usage
To create and show a bottomSheet, first of all, import the module at the beginning of the file:
import YYBottomSheet
First of all, you can show the bottomUpTable as below:
let bottomUpTable = YYBottomSheet.init(bottomUpTableTitle: title, dataArray: dataArray, options: nil) { cell in
// whatever you want to code
// print("\(cell.indexPath.row) : \(cell.titleLabel.text)")
}
bottomUpTable.show()
And button handler (SelectHandler) is just a lambda:
(YYBottomSheetCell) -> ()
Second, you can show the simpleToast as below:
let message = "Hello World!"
let simpleToast = YYBottomSheet.init(simpleToastMessage: message, options: nil)
simpleToast.show()
You can customize several things by setting options as below:
BottomUpTableOptions
option | example |
---|---|
allowTouchOutsideToDismiss | false |
backgroundAlpha | 0.3 |
tableViewHeight | 200 |
tableRowHeight | 50 |
tableViewCellLabelTextColor | UIColor.blue |
tableViewSeperatorStyle | UITableViewCell.SeparatorStyle.none |
tableViewBackgroundColor | UIColor.white |
headerViewBackgroundColor | UIColor.yellow |
headerViewTitleLabelTextColor | UIColor.red |
SimpleToastOptions
option | example |
---|---|
showDuration | 2.0 |
backgroundColor | UIColor.black |
beginningAlpha | 0.8 |
messageFont | UIFont.italicSystemFont(ofSize: 15) |
messageColor | UIColor.white |
Check full example as below:
/**
* BottomUpTable
*/
let title = "Fruits"
let dataArray = ["apple", "grape", "watermelon", "banana", "strawberry", "cherry", "pineapple", "pear"]
let options: [YYBottomSheet.BottomUpTableOptions:Any] = [
.allowTouchOutsideToDismiss: true,
.backgroundAlpha: 0.5,
.tableViewHeight: 200,
.tableRowHeight: 50,
.tableViewSeperatorStyle: UITableViewCell.SeparatorStyle.none
]
let bottomUpTable = YYBottomSheet.init(bottomUpTableTitle: title, dataArray: dataArray, options: options) { cell in
self.selectedFruitLabel.text = cell.titleLabel.text
}
bottomUpTable.show()
/**
* SimpleToast
*/
let options: [YYBottomSheet.SimpleToastOptions:Any] = [
.showDuration: 2.0,
.backgroundColor: UIColor.black,
.beginningAlpha: 0.8,
.messageFont: UIFont.italicSystemFont(ofSize: 15),
.messageColor: UIColor.white
]
let message = "SimpleToast can be customized!"
let simpleToast = YYBottomSheet.init(simpleToastMessage: message, options: options)
simpleToast.show()
Installation
YYBottomSheet is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'YYBottomSheet'
Author
DevYeom, [email protected]
License
YYBottomSheet is available under the MIT license. See the LICENSE file for more info.