How to change home indicator background color on iPhone X?

为君一笑 提交于 2019-11-28 06:59:55

问题


I would like to change the background color of the view that appears on the bottom of the new iPhone X with a home indicator inside.

Is it possible?


回答1:


The home indicator color is determined automatically based on the color of the content below it.

Most of the time, this means you should not worry about its color since it is out of your control, and will always be clearly visible to users.

However, you can place a colored view in the area behind the home indicator to manipulate its color.

Examples

(Please note that these examples were taken on the iOS simulator, and behavior on a real device is different.)

Background: white (#ffffff)

Home Indicator: black (#000000)


Background: black (#000000)

Home Indicator: gray (#484848)


Background: gray (#5f5f5f)

Home Indicator: dark gray (#282828)


Background: blue (#1a98fc)

Home Indicator: very dark gray (#121212)


I wrote an in-depth article about the home indicator color if you want to learn more about its behavior: Reverse-Engineering the iPhone X Home Indicator Color




回答2:


The home indicator (line) colour is set automatically based on the content below it, often the root view background.

To change the background colour use this:

self.window.rootViewController.view.backgroundColor = [UIColor colorWithWhite:0.98 alpha:1.0] ;



回答3:


You can add some negative distance between a colored view's bottom and the safe area's bottom.



来源:https://stackoverflow.com/questions/46194557/how-to-change-home-indicator-background-color-on-iphone-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!