0

I am trying to emulate a behavior of the home indicator on iPhone X but can't figure out how. In some apps, the home indicator goes dim, and you have to swipe it to activate normal behavior. I have found an option in the Controller to hide the indicator, but that isn't what I am looking for. In Clash Royale and Clash of Clans, for example, the home indicator dims, then when you swipe up on it the indicator gets brighter, and if you do it again it activates 'home'. Hiding the indicator using an API I found really just makes it behave weirdly.

This is the API I am using, but it doesn't work like I have seen in other apps. With auto hide on, the indicator will disappear until you swipe and immediately invokes the home action. That is no good because the purpose is to prevent inadvertent swipes going to the home screen:

override func prefersHomeIndicatorAutoHidden() -> Bool {
    return true
}

The behavior I prefer is for the indicator to dim, and then activate (get brighter) when you swipe up (but not go to home), then if you swipe up again to trigger home. This behavior is constant in Supercell apps, but perhaps it isn't a built-in behavior.

In order to see the difference, you can look at one of those Supercell apps (on an iPhone X), and look at an app with just the property set.

absmiths
  • 1,144
  • 1
  • 12
  • 21
  • 1
    Please, be a bit more specific. Include what you've tried. And again, be specific. Make it something we can reproduce. And YES AGAIN, be specific. –  Jan 02 '18 at 04:20
  • The property is the only thing I have been able to find to try, so that is the whole story there. I don't think I can describe the behavior any better without being redundant. The only way to describe it is to give an example - I have seen others but can't find them at the moment. – absmiths Jan 02 '18 at 04:56
  • 1
    Maybe you should be redundant? Not trying to sound facetious but what can we do to reproduce your issue? –  Jan 02 '18 at 06:13
  • I am trying to attach short screen captures of the relevant behavior to the question, but I can't quite figure out how. Any suggestions? Do I upload them to Dropbox then link somehow? I can do images, but not videos. – absmiths Jan 02 '18 at 18:08
  • After (re)reading your question very hard, two thoughts. (1) Be careful about "using an API" - make sure it's not a private one that will result in Apple rejecting the app. (2) It *does* sound like there are apps - games - that do what you want. Maybe they "recreate" the home indicator? My area of expertise/experience UI-wise is with `UIKit`, auto layout and safe areas, and clearly more "standard" than changing the behavior of the home indicator. I also have to wonder if those apps have the resources to do this, where you may not? Good luck! (I mean that sincerely.) –  Jan 02 '18 at 18:20
  • Thanks for trying to help. This can be a frustrating process and I appreciate your input. – absmiths Jan 02 '18 at 18:59

1 Answers1

7

I researched the question more and finally found the answer in this article: iPhone X: Dealing with Home Indicator

Emphasis here (I changed .top to .bottom since that is where the home indicator lives):

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
  return .top
}

What that does is defer the home action until the user performs the gesture once to activate the home control, and then a second time to invoke home. Now that I have found this I (ironically) probably won't use it. I will probably just leave enough extra room at the bottom. My problem isn't with the gesture, but with the indicator covering my content (probably needs a UI update, but I don't have time for that now).

Hopefully, someone else will find this useful since this behavior is pretty cool but difficult to discover.

absmiths
  • 1,144
  • 1
  • 12
  • 21
  • This is perfect. Everything else I've seen just hides it until the user taps the screen. This is great for games. – andrewlundy Apr 30 '20 at 00:37