Latest 1.0.2
Homepage https://github.com/nicol3a/NBBottomSheet
License MIT
Platforms ios 9.0, requires ARC
Frameworks Foundation, UIKit
Authors

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

Latest podspec

{
    "name": "NBBottomSheet",
    "version": "1.0.2",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/nicol3a/NBBottomSheet",
    "authors": {
        "Nicolas Bichon": "[email protected]"
    },
    "social_media_url": "http://twitter.com/nicol3a",
    "summary": "An iOS library that presents a bottom sheet using Auto Layout.",
    "source": {
        "git": "https://github.com/nicol3a/NBBottomSheet.git",
        "tag": "1.0.2"
    },
    "source_files": "NBBottomSheet/NBBottomSheet/Sources/**/*.{h,m,swift}",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This