NBBottomSheet
NBBottomSheet is an open-source iOS library that allows you to present a UIViewController
in a bottom sheet.
Requirements
- iOS 9.0+
- Xcode 11+
- Swift 5.0
Installation
CocoaPods
To integrate NBBottomSheet into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'NBBottomSheet', '~> 1.2'
end
Then, run the following command:
$ pod install
Carthage
To integrate NBBottomSheet into your Xcode project using Carthage, specify it in your Cartfile
:
github "nicol3a/NBBottomSheet" ~> 1.1
Then, run the following command:
$ carthage update
Drag the built NBBottomSheet.framework
from the Carthage build folder into the “Embedded Binaries” section in the "General" panel of the application target.
Manually
Add NBBottomSheet as a git submodule by running the following command:
$ git submodule add -b master https://github.com/nicol3a/NBBottomSheet.git
Drag the NBBottomSheet.xcodeproj
file into your project and add the NBBottomSheet.framework
in the "Embedded Binaries" section in the "General" panel of the application target.
Usage
Initialize an instance of NBBottomSheetController
:
let bottomSheetController = NBBottomSheetController()
To display a view controller in a bottom sheet, add the following code where you want to display the bottom sheet, passing the view controller to present and the container view controller:
let viewController = AlertViewController()
bottomSheetController.present(viewController, on: self)
Note: Be sure to keep a strong reference to your instance of
NBBottomSheetController
for the duration of its use.
If you don’t want to use NBBottomSheetController
’s default configuration, you can specify a NBBottomSheetConfiguration
instance on initialization of NBBottomSheetController
.
let configuration = NBBottomSheetConfiguration(animationDuration: 0.4, sheetSize: .fixed(300))
let bottomSheetController = NBBottomSheetController(configuration: configuration)
License
NBBottomSheet is available under the MIT license. See the LICENSE
file for more information.
Acknowledgements
- Created with
❤️ by Nicolas Bichon