iPhone-x full screen support for old projects

If you haven’t figured it out, this is what I’ve found that seems to work.

- (void)viewDidLoad {
    [super viewDidLoad];
    if (@available(iOS 11.0, *)) {
        // This should only be necessary if you changed the return value of the property
        // `BOOL preferredScreenEdgesDeferringSystemGestures`, but in limited testing needed this
        [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
    } else {
        // Fallback on earlier versions
    }
}

// NOTE(steve): meant more for hiding in passive use where touches are infrequent
- (BOOL)prefersHomeIndicatorAutoHidden {
    // NOTE(steve): setting this to yes causes the defer system edge gestures to not work
    //return YES;
    return NO;
}

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
    return UIRectEdgeAll;
    // NOTE(steve): should probably just defer the bottom swipe (home gesture)
    //return UIRectEdgeBottom;
}
4 Likes