SheetViewController
SheetViewController is a fully customizable and native-like alert sheet controller UI component written in Swift.
Features
- Three types of alerts: with inner action, with outer action, without action.
- Two alignment types of alerts: bottom, center.
- Fully customisation components. You can customise content (header, actions), color, fonts, forms, spaces and etc.
- Works on iPad.
- Easy to use.
- Works on both orientations: portrait, landscape.
UI customization Q&A
How to change the color?
How to change the corner radius?
How to change the spacing?
How to change sheet offsets?
Other settings
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
SheetViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
inhibit_all_warnings!
target 'YOUR_TARGET_NAME' do
use_frameworks!
pod 'SheetViewController'
end
Usage
import SheetViewController
// 'titleMessage' - title for alert.
// 'message' - message for alert.
// 'cancelTitle' - title for bottom button.
//
// 'customRowView' - the object of class 'UIView' or his inheritors.
// 'row' - the object of class 'SheetItemActionView'.
//
// 'alignmentType' values:
// - .bottom - displays an alert located at the bottom of the screen;
// - .center - displays an alert located at the center of the screen.
//
// 'actionType' values:
// - .separately - displays an alert with a bottom action button located separately;
// - .inner - displays an alert with an action button located insite the alert;
// - .none - displays an alert without a button.
let sheet = SheetViewController(
with: titleMessage,
message: message,
alignmentType: .bottom,
actionType: .separately) { configuration in
// UI customization (see UI customization Q&A section)
return configuration
}
present(sheet, animated: true, completion: nil)
sheet.addView(customRowView)
sheet.addRow(actionView: row)
sheet.setCancelButton(title: cancelTitle) {
print("Cancel button did click")
}
Demo
Author
License
SheetViewController is available under the MIT license. See the LICENSE file for more info.
Inspired by
Designing for iPhone in Figma - https://setproduct.com/ios
Used in project
Icons:
Icons8 - https://icons8.com