Skip to content

Commit

Permalink
docs: add info about safeAreaInsets into README.md + add iOS version …
Browse files Browse the repository at this point in the history
…validation to Demo project
  • Loading branch information
Friend-LGA committed Sep 6, 2024
1 parent 0214884 commit 745a927
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Demo/LGAlertViewDemo/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 745a927

Please sign in to comment.