Skip to content
An iOS library that presents a bottom sheet using Auto Layout.
Branch: master
Clone or download
Nicolas Bichon
Nicolas Bichon Update UI Tests
Latest commit 8b00ded Nov 20, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Update UI Tests Nov 19, 2018
NBBottomSheet Update podspec file and README Nov 13, 2018
.gitignore Initial commit Nov 10, 2018
.swift-version
LICENSE
NBBottomSheet.podspec Improve podspec content Nov 16, 2018
README.md Update README Nov 16, 2018

README.md

NBBottomSheet

Carthage Compatible CocoaPods Compatible Swift 4.2 Platform License

NBBottomSheet is an open-source iOS library that allows you to present a UIViewController in a bottom sheet.

The library relies on Auto Layout to calculate the size of the bottom sheet.

Demo

Requirements

  • iOS 9.0+
  • Xcode 10+
  • Swift 4.2

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.0.0'
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.0.0

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)
let bottomSheetController = NBBottomSheetController(configuration: configuration)

Auto Layout

The library relies on the view controller's Auto Layout constraints to calculate the size of the bottom sheet being presented.

You can either:

  • use Storyboards or xibs to create your view controller and set the Size to "Freeform" ("Simulated Metrics" section in the "Attributes inspector" panel),
  • or you can create your view programmatically.

License

NBBottomSheet is available under the MIT license. See the LICENSE file for more information.

Acknowledgements

You can’t perform that action at this time.