我的应用有04个标签,我想写一个功能来改变整个屏幕的背景颜色:状态栏,导航栏等。
我想要这个,因为当我在func中改变颜色时,整个应用程序将会改变
下面我只是改为顶部。但太复杂了
我所做的是将状态栏文本更改为白色
//change text of status bar to white
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
转到故事板,选择视图控制器,然后在编辑器菜单中选择嵌入导航控制器。选择导航栏,然后在“属性”检查器中将“条形”颜色设置为红色。
在appDelegate.swift中
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UINavigationBar.appearance().barStyle = .blackOpaque
return true
}