FloatingBottomSheet

1.0.0

An easy way to present a bottom sheet with a floating effect
OhKanghoon/FloatingBottomSheet

What's New

πŸš€ 1.0.0

2024-03-24T10:36:01Z

What’s Changed

😎 Update

πŸ€“ Improvements

  • Improving Layout Configuration of Bottom Sheet @OhKanghoon (#9)

FloatingBottomSheet

Logo
CI Supported Platforms: iOS CocoaPods

A library that displays floating bottom sheet.

Compatibility

FloatingBottomSheet requires iOS 11+ and is compatible with Swift 5 projects.

Installation

The preferred way of installing FloatingBottomSheet is via the Swift Package Manager

  1. In Xcode, open your project and navigate to File β†’ Add Packages
  2. Paste the repository URL (https://github.com/OhKanghoon/FloatingBottomSheet) and click Next.
  3. For Rules, select Up to Next Major Version.
  4. Click Add Package.
# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
  pod 'FloatingBottomSheet'
end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Usage

Configuration

To use the FloatingBottomSheet, your ViewController must conform to the FloatingBottomSheetPresentable protocol.

Start by implementing the bottomSheetScrollable and bottomSheetHeight properties.

final class ViewController: UIViewController, FloatingBottomSheetPresentable {
  
  var bottomSheetScrollable: UIScrollView? { 
    // Return a scrollable view
  }
    
  var bottomSheetHeight: CGFloat { 
    // Set the height of the bottom sheet
  }
}

Present bottom sheet

Simply present the floating bottom sheet using the presentFloatingBottomSheet function like this:

let viewController = ViewController()

presentFloatingBottomSheet(viewController)

Updates bottom sheet height at runtime

To update the bottom sheet's height dynamically during runtime, use the following code:

bottomSheetHeight = 400.0
bottomSheetPerformLayout(animated: true)

You can change the value of bottomSheetHeight to your desired height and then call bottomSheetPerformLayout function to update the bottom sheet's height with optional animation.

If you don't want animation, set animated to false.

License

FloatingBottomSheet is under MIT license. See the LICENSE for more info.

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Apr 28 2024 09:17:33 GMT-0900 (Hawaii-Aleutian Daylight Time)