Features | |
---|---|
๐ | Apple Maps bottom sheet behaviour |
โ | Supports panning with UIScrollView and UIView |
๐ | Allows adding dimmable background view |
๐ฑ | Set sheet content as UIViewController or UINavigationController |
๐ | Navigation inside sheet with UINavigationController |
๐ | Add one or more sheet stop positions |
๐ฏ | Change sheet position programmatically |
๐ | Present as many sheet as you want |
๐ | Move multiple sheets simultaneously or seperately |
๐น | Rubber banding |
๐ | Dismiss at bottom |
Apple Maps & Childs | Navigation In Sheet | Pull To Dismiss | Multiple Sheet Positions |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
To run the example project, clone the repo, and run pod install
from the Example directory first.
Bottom sheet child view controllers must conform to the Draggable protocol.
class MapsDemoBottomSheetController: UIViewController, Draggable{
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
tableView.delegate = self
tableView.dataSource = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//adds pan gesture recognizer to draggableView()
sheetCoordinator?.startTracking(item: self)
}
// MARK: Draggable protocol implementations
var sheetCoordinator: UBottomSheetCoordinator?
func draggableView() -> UIScrollView? {
return tableView
}
}
Create a UBottomSheetCoordinator from the main view controller. Use the UBottomSheetCoordinator to add and configure the sheet.
// parentViewController: main view controller that presents the bottom sheet
// call this within viewWillLayoutSubViews to make sure view frame has measured correctly. see example projects.
let sheetCoordinator = UBottomSheetCoordinator(parent: parentViewController)
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MapsDemoBottomSheetController") as! MapsDemoBottomSheetController
vc.sheetCoordinator = sheetCoordinator
sheetCoordinator.addSheet(vc, to: parentViewController)
ios9.0+, Xcode10+
UBottomSheet is available through CocoaPods and Swift Package Manager.
Add the following line to your Podfile:
pod 'UBottomSheet'
Add this url in XCode > File > Swift Packages > Add Package Dependency:
https://github.com/OfTheWolf/UBottomSheet
TwitterProfile Nested scroll view behaviour of Twitter Profile screen.
uฤur, [email protected]
UBottomSheet is available under the MIT license. See the LICENSE file for more info.