如何以编程方式更改iPhone X的底边颜色?

问题描述:

它在原生键盘/表情符号板上会发生变化,这取决于两者中的哪一个是打开的。我认为它会根据 UIInputViewController 自动更改颜色,但是自定义键盘扩展名不会出现这种情况:

It changes on their native keyboard/emoji board, depending which of the two are open. I thought it would change the color automatically based on UIInputViewController, however it is not occurring with custom keyboard extensions:

您可以采取一些措施来解决这个问题。为主页指示符更改 ViewController的View backgroundcolor 。并根据您的需要通过编码分别设置状态栏外观

One thing you can do to solve this. Change backgroundcolor of your ViewController's View for home indicator. And set status bar appearance separately through coding as per your needs.

这将更改您的主页指示符状态栏颜色加上安全区域巧克力色,添加单独视图安全区域为您的其他设计,因为我添加了黄色

This will change your home indicator, status bar color plus a safe area to Chocolate color, Add separate view in safe area for your other design, as I've added yellow.

如果你想要状态栏的颜色不同

If you want different color for your status bar, call it somewhere from viewDidLoad with color you want -

func setStatusBarBackgroundColor(color: UIColor) {

        guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }
        statusBar.backgroundColor = color
    }  

除此之外,您将无法在外观中进行任何其他更改,至少现在直到苹果提供任何方法来控制外观 主页指标。我来给你展示。

Apart from this, You won't be able to do any other changes in appearance, at least for now till apple provides any way to control appearance of home indicator. let me show you.

这些是酒吧的可用性,你在哪里可以控制它的外观。没有主页指示栏选项Apple已提供更改。

These are the availability of bars, where you can control appearance of it. There is no home indicator bar option Apple has provide for it's alteration.

这些是你可以控制外观的唯一条形码 -

导航栏

搜索栏

状态栏

标签栏

工具栏

These are the only bars you can control appearance -
Navigation Bars
Search Bars
Status Bars
Tab Bars
Tool Bars

推荐链接 - iPhone-X接口指南