QuickSheet is a wrapper for UIViewController to handle bottom sheet presentation (a.k.a pop-ups) with low code footprint and a high degree of customisation.
Bottom Sheet / Pop-up view presentation in iOS is only available (natively) in iOS 15 with limited functionality that's only expanded upon in iOS 16. Attempting to replicate the effect in prior versions of iOS could include adding multiple modifications to how you build your views and view controllers that might make it more difficult to migrate to the native soultion when it hits the mainstream especially in large scale applications.
You can present the target view controller without any modifications to it by calling self.presentQuickSheet
method with the standard options
self.presentQuickSheet(targetVC, options: .standard)
You can customise the standard options at the app delegate after the app launch
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
QuickSheetOptions.standard = QuickSheetOptions(
fraction: 0.75,
presentationStyle: .regular,
cornerRadius: 10,
blurEffect: .regular,
shadowStyle: .standard
)
return true
}
Most of the settings you'd only need to change once. only the fraction and the presentation style depend on what kind of view you're presenting. So, now you have direct access to them without needing to create a custom options object to modify one or two parameters.
self.presentQuickSheet(targetVC, fraction: 0.5)
self.presentQuickSheet(targetVC, fraction: 0.5, presentationStyle: .scrollable)
You can customise the presentation by creating a new options constant
let customOptions = QuickSheetOptions(fraction: 0.3,
presentationStyle: .expandable,
cornerRadius: 10,
blurEffect: .systemMaterial,
shadowStyle: .standard)
self.presentQuickSheet(targetVC, options: customOptions)
Here's how you can use QuickSheetOptions
to customise your pop-up
fraction
: Represents the height of the sheet as a percentage of the screen heightpresentationStyle
: The sheet's presentation style; regular, expandable or scrollable.cornerRadius
: Changing this value determines the radius of the top left and right cornersblurEffect
: Choose a background effect from a system-defined listUIBlurEffect.Style
. Setting this to nil removes the blur effect and replaces it with a 75% opaque black backgroundshadowStyle
: Determines the shadow style of the pop-up. Set to.standard
to use the default configuration or create your ownQuickSheetOptions.ShadowStyle
constant as follows
let shadowStyle = QuickSheetOptions.ShadowStyle(shadowRadius: 10.0,
shadowColor: .black,
shadowOpacity: 0.25)
- You can view the QuickSheet demo here
- To run the example project, clone the repo, and run
pod install
from the Example directory first.
QuickSheet is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'QuickSheet'
QuickSheet is available under the MIT license. See the LICENSE file for more info.