mirror of
https://github.com/godotengine/godot.git
synced 2024-12-09 10:09:20 +08:00
Merge pull request #40761 from naithar/feature/ios-safe_area
[iOS] Safe area reimplementation
This commit is contained in:
commit
35ff38b3d4
@ -492,7 +492,22 @@ Size2i DisplayServerIPhone::screen_get_size(int p_screen) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rect2i DisplayServerIPhone::screen_get_usable_rect(int p_screen) const {
|
Rect2i DisplayServerIPhone::screen_get_usable_rect(int p_screen) const {
|
||||||
return Rect2i(screen_get_position(p_screen), screen_get_size(p_screen));
|
if (@available(iOS 11, *)) {
|
||||||
|
UIEdgeInsets insets = UIEdgeInsetsZero;
|
||||||
|
UIView *view = AppDelegate.viewController.godotView;
|
||||||
|
|
||||||
|
if ([view respondsToSelector:@selector(safeAreaInsets)]) {
|
||||||
|
insets = [view safeAreaInsets];
|
||||||
|
}
|
||||||
|
|
||||||
|
float scale = screen_get_scale(p_screen);
|
||||||
|
Size2i insets_position = Size2i(insets.left, insets.top) * scale;
|
||||||
|
Size2i insets_size = Size2i(insets.left + insets.right, insets.top + insets.bottom) * scale;
|
||||||
|
|
||||||
|
return Rect2i(screen_get_position(p_screen) + insets_position, screen_get_size(p_screen) - insets_size);
|
||||||
|
} else {
|
||||||
|
return Rect2i(screen_get_position(p_screen), screen_get_size(p_screen));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerIPhone::screen_get_dpi(int p_screen) const {
|
int DisplayServerIPhone::screen_get_dpi(int p_screen) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user