iPhone X disabling/hiding home indicator line in SDL2

The “new” iPhone X doesn’t have the home button anymore, instead there is a line drawn on the bottom of the screen that you swipe some way to get to the home screen.
There are two ways to hide it in the viewcontroller. One hides it but the swipe function will work right away, or you can hide (actually dim it) it and when you swipe, it will reappear and only then on another swipe get you to the home screen.
On stackoverflow you can find the two examples https://stackoverflow.com/questions/46692121/iphone-x-hide-home-indicator-on-view-controller .
To just hide it:

override func prefersHomeIndicatorAutoHidden() -> Bool {
        return true

To hide and make it two swipes:

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
  return .bottom

But how to implement this in an SDL2 project? I guess it would need to be implemented in SDL’s viewcontroller code and probably needs a bool hint to toggle it.

Ok, I think I got it. Partially…

When I add in SDL_uikitappdelegate.m:285 either of these it works like this:

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
    return UIRectEdgeBottom;

-> the Home indicator is dimmed/transparent and will only react to the second swipe. This way you can implement your own swipe gesture and/or the indicator looks a bit less obtrusive.

    return YES;

-> the Home indicator is hidden BUT will always reappear when you touch the screen. This is only useful for an app like a video player (when you don’t have much interaction with the screen for longer periods).

You CANNOT use both, prefersHomeIndicatorAutoHidden takes over and will not honor preferredScreenEdgesDeferringSystemGestures.

I was not able to make use of it in an actual hijack of the SDL AppDelegate, though, only with the above change.

After more investigation, I found that I needed it in both SDL_uikitappdelegate.m under the @implementation SDLLaunchScreenController and in SDL_uikitviewcontroller.m under @implementation SDL_uikitviewcontroller or it wouldn’t “stick”

I made a bug report at https://bugzilla.libsdl.org/show_bug.cgi?id=4059

It should be enough to add this in SDL_uikitviewcontroller.m but it seems there is something odd going on with the SDL_uikitmessagebox.m code. When you show an alert either of these methods to handle the Home indicator do no longer work.

A good testcase is testsprite.c:

  • in the void loop, while (SDL_PollEvent(&event)) { add switch and a case SDL_FINGERDOWN to show a simple SDL Messagebox:
    /* Check for events */
    while (SDL_PollEvent(&event)) {
    switch (event.type) {
    “Simple MessageBox”, “Just a simple messagebox”, NULL);

  • add -(BOOL)prefersHomeIndicatorAutoHidden in SDL_uikitviewcontroller.m

  • when you run the testsprite2 test via TestiPhoneOS.xcodeproj the Home indicator will be hidden after second. When you touch the screen the SDL Messagebox will show, cancel it and the Home indicator will no longer hide.

Hello Dominus,

Do you get the iPhone X full screen resolution? Because I am getting, 2001x1125, for some reason it cuts the height for me.


Yes I get the full screen on the X (2436x1125). But I had to adapt the launch images https://github.com/litchie/exult-ios/commit/2fdb17e3994750521cd1a37e9efd4e5fb7748445 and then it worked right away

Hello Dominus,

Thanks that worked!


Great! Thanks for “reporting” back :wink: