A lightweight, customizable bottom sheet component for iOS built with Swift using UIPresentationController.
- Custom presentation via
UIPresentationController— works with standardpresent(_:animated:)flow - Swipe-to-dismiss with velocity-based threshold
- Tap on dimming background to dismiss
- Scroll view coordination — pan gesture seamlessly hands off to an embedded scroll view
- Dynamic content height via delegate
- Rounded top corners with a drag indicator (handle)
- Safe area support (top and bottom insets)
- Supports iOS 12+ with adaptive colors for Dark Mode (iOS 13+)
| Minimum | |
|---|---|
| iOS | 12.0+ |
| Swift | 5.9+ |
| Xcode | 15.0+ |
Add the dependency to your Package.swift:
dependencies: [
.package(url: "https://github.com/Areal-Group/ARBottomSheetViewController.git", .upToNextMajor(from: "1.0.0"))
]Or in Xcode: File → Add Package Dependencies… and paste the repository URL.
let bottomSheet = ARBottomSheetViewController()
bottomSheet.sheetDelegate = selflet label = UILabel()
label.text = "Hello, Bottom Sheet!"
bottomSheet.contentBackgroundView.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
label.topAnchor.constraint(equalTo: bottomSheet.contentBackgroundView.topAnchor, constant: 16),
label.leadingAnchor.constraint(equalTo: bottomSheet.contentBackgroundView.leadingAnchor, constant: 16),
label.trailingAnchor.constraint(equalTo: bottomSheet.contentBackgroundView.trailingAnchor, constant: -16),
label.bottomAnchor.constraint(equalTo: bottomSheet.contentBackgroundView.bottomAnchor, constant: -16)
])present(bottomSheet, animated: true)extension YourViewController: ARBottomSheetViewControllerDelegate {
var contentHeight: CGFloat {
return 300
}
var childScrollView: UIScrollView? {
return nil // or return a scroll view for coordinated scrolling
}
}If you return a UIScrollView from childScrollView, the bottom sheet will coordinate its dismiss gesture with the scroll view — swiping down only dismisses the sheet when the scroll view is at the top of its content.
public protocol ARBottomSheetViewControllerDelegate: AnyObject {
var contentHeight: CGFloat { get }
var childScrollView: UIScrollView? { get }
}| Property | Description |
|---|---|
contentHeight |
The desired height of the content area (excluding the handle and safe area) |
childScrollView |
Optional scroll view for coordinated pan gesture handling |
| Property / Method | Description |
|---|---|
sheetDelegate |
Weak reference to ARBottomSheetViewControllerDelegate |
contentBackgroundView |
The view where you should add your content subviews |
init() |
Creates a new bottom sheet instance |
This project is licensed under the MIT License — see the LICENSE file for details.