当前位置:   article > 正文

mac反向控制iphone_反向工程iPhone X Home指示灯颜色

mac控制iphone

mac反向控制iphone

by Nathan Gitter

内森·吉特(Nathan Gitter)

反向工程iPhone X Home指示灯颜色 (Reverse-Engineering the iPhone X Home Indicator Color)

I noticed an unusual behavior of the iPhone X home indicator while working on my most recent app. The app’s background near the home indicator is purple. When the app launches, the home indicator is very light gray.

在使用最新的应用程序时,我注意到iPhone X家用指示器的异常行为。 主屏幕指示器附近的应用程序背景为紫色。 应用启动时,主页指示灯会非常浅灰色。

But something odd happened when I pressed the app’s “share” button, which opened a default iOS activity view (aka “share sheet”). When I hit the “cancel” button to close the activity view, the home indicator animated to a dark gray color.

但是,当我按下应用程序的“共享”按钮时,发生了一些奇怪的事情,该按钮打开了默认的iOS活动视图(也称为“共享表”)。 当我点击“取消”按钮以关闭活动视图时,主页指示器会变为深灰色。

Even though the background color was exactly the same, the light-colored activity view passing underneath caused the home indicator to change color. The only way to get the home indicator back to its original color was to leave the app and come back.

即使背景颜色完全相同,下面经过的浅色活动视图也会使主页指示器更改颜色。 使主页指示器恢复其原始颜色的唯一方法是离开应用程序并返回。

I had never seen this before, and it prompted my curiosity.

我以前从未见过,这引起了我的好奇心。

What determines the color of the home indicator and why it does it behave like this? The answer is surprisingly complex. Let’s take a deep dive and see what we can learn!

是什么决定了首页指示器的颜色,以及为什么它会如此表现? 答案非常复杂。 让我们深入学习,看看我们能学到什么!

家庭指标基础 (Home Indicator Basics)

In September 2017, Apple introduced its newest iteration of mobile phone: iPhone X. The new design replaced the iconic home button with on-screen gestures. To go home, the user simply swipes up from the bottom of the screen.

2017年9月,苹果推出了其最新的手机版本:iPhone X.新设计用屏幕手势取代了标志性的主页按钮。 要回家,用户只需从屏幕底部向上滑动即可。

房屋指标的目的 (The Home Indicator’s Purpose)

To create the affordance of being able to swipe up from the bottom of the screen, Apple added a small horizontal bar known as the home indicator. The home indicator is always present except for the home screen and in any apps that request it to be temporarily hidden (full-screen video, games, etc.).

为了提供能够从屏幕底部向上滑动的功能,Apple添加了一个称为水平指示器的小水平条。 主屏幕指示符始终存在,除了主屏幕以及要求将其暂时隐藏的所有应用(全屏视频,游戏等)。

The home indicator serves another purpose: protecting the bottom edge of the screen from conflicting user interface elements and gestures. Because the user needs to be able to swipe up from the bottom of the screen at any time, best practices now dictate that developers should avoid place conflicting gestures or buttons in the bottom edge of the display.

主页指示器的另一个作用是:保护屏幕的底部边缘免受冲突的用户界面元素和手势的影响。 由于用户需要能够随时从屏幕底部向上滑动,因此最佳实践现在要求开发人员应避免在屏幕的底部边缘放置冲突的手势或按钮。

By placing a bar at the bottom, user interface elements in the same location look wrong—there’s a visual conflict between the bar and other elements. In this sense, the home indicator “protects” this region of the screen from designers or engineers that are unaware of the functionality of the iPhone X.

通过在底部放置一个栏,位于同一位置的用户界面元素看起来是错误的 -栏和其他元素之间存在视觉冲突。 从这个意义上讲,主页指示器可以“保护”屏幕的这一区域,以防止不知道iPhone X功能的设计师或工程师。

Now that we’re all on the same page, let’s get back to our original question: “What color is the home indicator?”

现在我们都在同一页面上,让我们回到最初的问题:“主页指示器是什么颜色?”

第1部分-起点 (Part 1 — The Beginning)

On September 13, 2017, I answered a Stack Overflow question asking how to change the color of the home indicator.

2017年9月13日,我回答了一个堆栈溢出问题,询问如何更改归位指示器的颜色。

At the time, the iPhone X hadn’t been publicly released, but the latest version of Xcode included an iPhone X simulator. Running a simple test app in the simulator revealed that the home indicator’s color was based on the color of the content below it.

当时,iPhone X尚未公开发布,但最新版本的Xcode包括一个iPhone X模拟器。 在模拟器中运行一个简单的测试应用程序后发现,归位指示器的颜色基于其下方内容的颜色。

The new APIs for the iPhone X were released alongside this same version of Xcode, and there was no public API available to modify the color of the home indicator (which is still the case at the time of writing this post, and probably will always be the case).

iPhone X的新API与相同版本的Xcode一起发布,并且没有公共API可用于修改home指示器的颜色(撰写本文时仍是这种情况,并且可能永远是案子)。

This made my Stack Overflow answer simple and straightforward: it is not possible to modify the color, and you shouldn’t worry about it, since it’s out of your control and guaranteed to be visible.

这使我的Stack Overflow答案变得简单明了:无法修改颜色,并且您不必担心它,因为它不受您控制并且可以保证可见。

Because I anticipated this to be a common question, I included some screenshots of the home indicator on top of va

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/726317
推荐阅读
  

闽ICP备14008679号