Bottom sheet popover built with Swift & UIKit

BottomSheet

Bottom sheet popover built with Swift & UIKit.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To integrate BottomSheet into your project using CocoaPods, specify it in your Podfile:

pod 'IDBottomSheet'

After that use pod install command in your terminal.

Manually

If you prefer not to use any dependency managers, you can integrate BottomSheet into your project manually by downloading the desired release and copying the Sources directory.

Usage

Creation

Subclass BottomSheetViewController, then override viewDidLoad like this:

class ViewController: BottomSheetViewController {
    override func viewDidLoad() {
        viewController = BottomSheetContentsViewController() //your view controller
        isHalfPresentationEnabled = true //or false
        super.viewDidLoad()
    }
}

Note that super.viewDidLoad() must be called after you set BottomSheetViewController properties.

Enable Half Presentation

To enable half presentation set isHalfPresentationEnabled property to true.

isHalfPresentationEnabled = false isHalfPresentationEnabled = true

Animation Duration

To change animation duration set animationDuration property.

Popover Start & End Height

To modify popover startHeight & endHeight call setupSizeWith(startHeight: CGFloat, endHeight: CGFloat) function.

Behaviour

BottomSheet recognizes taps on the handler and recognizes swipes across the entire view.
In addition, BottomSheet analyzes how fast you swipe and where you swipe. This means that if you swipe slowly and the swipe endpoint is less than half of the popup's height, the presentation will be canceled. If you swipe quickly, the popup will always be presented.

Example

This repository contains example where you can see how BottomSheet can be used for presenting Apple Music player popover.

GitHub