https://github.com/aaronlab/dynamicbottomsheet
Customizable Dynamic Bottom Sheet Library for iOS
https://github.com/aaronlab/dynamicbottomsheet
bottomsheet cocoapods ios library nostoryboard spm swift swift5 swiftpackage swiftpackagemanager uikit
Last synced: 3 months ago
JSON representation
Customizable Dynamic Bottom Sheet Library for iOS
- Host: GitHub
- URL: https://github.com/aaronlab/dynamicbottomsheet
- Owner: aaronlab
- License: mit
- Created: 2021-11-07T04:49:11.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-17T13:27:59.000Z (almost 4 years ago)
- Last Synced: 2025-06-05T10:48:51.354Z (4 months ago)
- Topics: bottomsheet, cocoapods, ios, library, nostoryboard, spm, swift, swift5, swiftpackage, swiftpackagemanager, uikit
- Language: Swift
- Homepage:
- Size: 2.7 MB
- Stars: 15
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DynamicBottomSheet
[](https://cocoapods.org/pods/DynamicBottomSheet)
[](https://developer.apple.com/swift)


[](https://cocoapods.org/pods/DynamicBottomSheet)
[](https://cocoapods.org/pods/DynamicBottomSheet)Fully Customizable Dynamic Bottom Sheet Library for iOS.
This library doesn't support storyboards.
However, you can easily override variables in DynamicBottomSheetViewController and make the bottom sheet programmatically.
## Preview
[](./resources/preview.gif)
## Requirements
- Swift 5
- iOS 10.0 +
- RxSwift 6.0
- RxCocoa 6.0
- RxGesture 4.0
- SnapKit 5.0
- Then 2.0
## Installation
### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html)
DynamicBottomSheet is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'DynamicBottomSheet'
``````commandline
$ pod install
```### [Swift Package Manager(SPM)](https://www.swift.org/package-manager/)
In Xcode, add as Swift package with this URL: `https://github.com/aaronLab/DynamicBottomSheet`
## Usage
1. Import `DynamicBottomSheet` on top of your view controller file.
2. Create a class for the bottom sheet where its super class is `DynamicBottomSheetViewController`.
3. Put the view you want to show in the `contentView` of the super class `DynamicBottomSheetViewController`.
4. Make `constraints of the view you made` to the `contentView` above.
5. `Present the bottom sheet view controller` you made before in another view controller.
## Example
For more examples, clone the repo, and run `pod install` from the Example directory.
```swift
import UIKit
import DynamicBottomSheet
import SnapKit
import Thenclass MyStackViewBottomSheetViewController: DynamicBottomSheetViewController {
// MARK: - Private Properties
private let stackView = UIStackView()
.then {
$0.axis = .vertical
$0.spacing = 32
$0.alignment = .fill
$0.distribution = .fillEqually
}}
// MARK: - Layout
extension MyStackViewBottomSheetViewController {
override func configureView() {
super.configureView()
layoutStackView()
}private func layoutStackView() {
contentView.addSubview(stackView)
stackView.snp.makeConstraints {
$0.top.equalToSuperview().offset(16)
$0.leading.equalToSuperview().offset(16)
$0.trailing.equalToSuperview().offset(-16)
$0.bottom.equalTo(view.safeAreaLayoutGuide).offset(-16)
}Array(1...5).forEach {
let label = UILabel()
label.text = "\($0)"
stackView.addArrangedSubview(label)}
}
}
``````swift
import UIKitclass ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()let bottomSheet = MyStackViewBottomSheetViewController()
DispatchQueue.main.async {
self.present(bottomSheet)
}
}
}
```## Customization
```swift
/// The background color of the view controller below the content view.
///
/// - `UIColor.black.withAlphaComponent(0.6)` for others.
open var backgroundColor: UIColor/// Background view
open var backgroundView: UIView/// The background color of the content view.
///
/// Default value
/// - `UIColor.tertiarySystemBackground` for iOS 13 or later.
/// - `UIColor.white` for others.
open var contentViewBackgroundColor: UIColor/// The height of the content view.
///
/// Default value is `nil`
///
/// If you set this value explicitly, the height of the content view will be fixed.
open var height: CGFloat?/// Content view
open var contentView: UIView/// Corner radius of the content view(top left, top right)
///
/// Default value is `16.0`
open var contentViewCornerRadius: CGFloat/// Present / Dismiss transition duration
///
/// Default value is 0.3
open var transitionDuration: CGFloat/// Dismiss velocity threshold
///
/// Default value is 500
open var dismissVelocityThreshold: CGFloat
```## Author
[Aaron Lee](https://github.com/aaronLab), aaronlab.net@gmail.com
## License
DynamicBottomSheet is available under the MIT license. See the LICENSE file for more info.