简体   繁体   中英

iPhone X home indicator behavior

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM