From 79431159fa2d0891bf5ffe152df6deb695fc0e5e Mon Sep 17 00:00:00 2001 From: Duy Tran Khanh Date: Fri, 19 Feb 2021 16:40:58 +0700 Subject: [PATCH] [Experimental] Add offset for iPhone notch cutout --- Natives/SurfaceViewController.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Natives/SurfaceViewController.m b/Natives/SurfaceViewController.m index 71311ca6..4ef2caac 100644 --- a/Natives/SurfaceViewController.m +++ b/Natives/SurfaceViewController.m @@ -69,13 +69,18 @@ BOOL shouldTriggerClick = NO; CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; + UIEdgeInsets insets = [[[UIApplication sharedApplication] keyWindow] safeAreaInsets]; + int width = (int) roundf(screenBounds.size.width); int height = (int) roundf(screenBounds.size.height); savedWidth = roundf(width * screenScale); savedHeight = roundf(height * screenScale); + + width = width - insets.top; + height = height - insets.bottom; - touchView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; + touchView = [[UIView alloc] initWithFrame:CGRectMake(insets.top, 0, width, height)]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(surfaceOnClick:)]; tapGesture.numberOfTapsRequired = 1;