Hi all,
I am making some existing game apps compatible with iPhone X. All these games are simply using a fillscreen window and have all their elements drawn manually in OpenGL. I want to make sure buttons and things avoid the notch. I'm not using any storyboards or anything fancy, the initialization is very lightweight.
How can I get the size of the notch? I'm using Objective-C. I'm just looking for a simplest possible call that I can use to say "okay, keep all game UI elements to the right of pixel position x."
Thanks!
Okay, simple enough. Is there a nice easy Obj-C call to get that safe area? Remember, I just have a full screen view, and I draw everywhere-- I just want to get the values of the margins that let me stay inside it.
(Edit) Answered my own question...
UIWindow* window=[[UIApplication sharedApplication] keyWindow];
float reservedTop=window.safeAreaInsets.top;
float reservedBottom=window.safeAreaInsets.bottom;
float reservedLeft=window.safeAreaInsets.left;
float reservedRight=window.safeAreaInsets.right