Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.
/ BottomSheet Public archive

Bottom sheet popover built with Swift & UIKit

License

Notifications You must be signed in to change notification settings

IrelDev/BottomSheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) method.

Popover Corner Radius

To modify popover corner radius for all states call setupCornerRadiusForState(collapsed: CGFloat, halfPresented: CGFloat, expanded: CGFloat) method. To modify popover corner radius for a single state call setupCornerRadiusForState(state: State, value: CGFloat) method.

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.

License

BottomSheet is available under the MIT license, see the LICENSE file for more information.