使用Xcode和Swift创建的iOS应用中状态栏的自定义背景颜色 [英] Custom background color for status bar in iOS app created with Xcode and Swift

查看:379
本文介绍了使用Xcode和Swift创建的iOS应用中状态栏的自定义背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经谷歌搜索了一下但没有成功。
我希望所有ViewControllers中的状态栏都有自定义背景颜色(仅限纵向模式)。 ViewControllers使用TabBarController进行管理。

I already googled a little bit but without success. I want to have a custom background color for the status bar in all my ViewControllers (only in portrait mode). The ViewControllers are managed with a TabBarController.

有人知道怎么做吗?也许有人有代码样本?

Does anybody know how to do that? Maybe anybody has a code sample?

推荐答案

我已经通过在状态栏下面放置一个UIView并设置了背景来解决问题颜色。但是我必须清除所有约束并再次添加它们以使UIView隐藏在横向模式中。

I already solved the problem myself by putting a UIView below the Status bar and set the background color. But I had to clear all constraints and add them again to make the UIView hiding in landscape mode.

这篇关于使用Xcode和Swift创建的iOS应用中状态栏的自定义背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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