xcode 如何更改 iPhone X 上的主页指示器背景颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46194557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change home indicator background color on iPhone X?
提问by Fengson
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.
我想更改出现在新 iPhone X 底部的视图的背景颜色,里面有一个主页指示器。
Is it possible?
是否可以?
回答by nathangitter
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.)
(请注意,这些示例是在 iOS 模拟器上进行的,在真实设备上的行为是不同的。)
Background:white (#ffffff
)
背景:白色 ( #ffffff
)
Home Indicator:black (#000000
)
主页指示灯:黑色 ( #000000
)
Background:black (#000000
)
背景:黑色 ( #000000
)
Home Indicator:gray (#484848
)
主页指示灯:灰色 ( #484848
)
Background:gray (#5f5f5f
)
背景:灰色 ( #5f5f5f
)
Home Indicator:dark gray (#282828
)
主页指示灯:深灰色 ( #282828
)
Background:blue (#1a98fc
)
背景:蓝色 ( #1a98fc
)
Home Indicator:very dark gray (#121212
)
主页指示灯:深灰色 ( #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
如果您想了解有关其行为的更多信息,我写了一篇有关主页指示灯颜色的深入文章:反向工程 iPhone X 主页指示灯颜色
回答by A.Badger
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] ;
回答by diegotrevisan
You can add some negative distance between a colored view's bottom and the safe area's bottom.
您可以在彩色视图的底部和安全区域的底部之间添加一些负距离。