iPhone X 主页指示灯行为 [英] iPhone X home indicator behavior

查看:35
本文介绍了iPhone X 主页指示灯行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 iPhone X 上模拟主页指示器的行为,但不知道如何进行.在某些应用程序中,主页指示灯变暗,您必须滑动它才能激活正常行为.我在控制器中找到了一个隐藏指示器的选项,但这不是我想要的.例如,在 Clash Royale 和 Clash of Clans 中,home 指示灯变暗,然后当你向上滑动它时,指示灯变亮,如果你再次这样做,它会激活home".使用我发现的 API 隐藏指标只会让它表现得很奇怪.

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.

这是我正在使用的 API,但它不像我在其他应用程序中看到的那样工作.启用自动隐藏后,指示器将消失,直到您滑动并立即调用主页操作.这不好,因为目的是防止无意中滑动到主屏幕:

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
}

我更喜欢的行为是指示灯变暗,然后在您向上滑动(但不是回家)时激活(变亮),然后再次向上滑动以触发主页.这种行为在 Supercell 应用中是固定的,但可能不是内置行为.

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.

要查看差异,您可以查看其中一个 Supercell 应用(在 iPhone X 上),然后查看仅设置属性的应用.

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.

推荐答案

我仔细研究了这个问题,终于在这篇文章中找到了答案:iPhone X:处理家庭指示器

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

此处强调(我将 .top 更改为 .bottom,因为这是 home 指示器所在的位置):

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

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

这样做是推迟 home 操作,直到用户执行一次手势以激活 home 控件,然后第二次调用 home.既然我已经找到了这个,我(讽刺的是)可能不会使用它.我可能只会在底部留下足够的额外空间.我的问题不在于手势,而在于指示器覆盖了我的内容(可能需要更新 UI,但我现在没有时间).

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.

这篇关于iPhone X 主页指示灯行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆