From 745a927b28c9925302206caa658ee59af3c9d949 Mon Sep 17 00:00:00 2001 From: Grigorii Lutkov Date: Sat, 7 Sep 2024 00:46:04 +0300 Subject: [PATCH] docs: add info about safeAreaInsets into README.md + add iOS version validation to Demo project --- Demo/LGAlertViewDemo/AppDelegate.m | 4 +++- README.md | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Demo/LGAlertViewDemo/AppDelegate.m b/Demo/LGAlertViewDemo/AppDelegate.m index bceb1e4..e0024aa 100644 --- a/Demo/LGAlertViewDemo/AppDelegate.m +++ b/Demo/LGAlertViewDemo/AppDelegate.m @@ -19,7 +19,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [self.window makeKeyAndVisible]; // Set default action sheet offset equal to safe area of the screen - [[LGAlertView appearance] setCancelButtonOffsetY: UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom]; + if (@available(iOS 11.0, *)) { + [LGAlertView appearance].cancelButtonOffsetY = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom; + } return YES; } diff --git a/README.md b/README.md index d4c1b56..70ed00f 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,27 @@ LGAlertView.appearance()... LGAlertView.appearance()... ``` +### Action Sheet Safe Area + +By default `LGAlertView` with `LGAlertViewStyleActionSheet` style doesn't use safe area insets. +So for now it's up to you to set the offset, and it as easy as this: + +##### Objective-C + +```objective-c +if (@available(iOS 11.0, *)) { + [LGAlertView appearance].cancelButtonOffsetY = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom; +} +``` + +##### Swift + +```swift +if #available(iOS 11.0, *) { + LGAlertView.appearance().cancelButtonOffsetY = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom +} +``` + ### Buttons If you want to set properties for each button individually, you can use method: