更改导航控制器颜色迅速 [英] Changing Navigation Controller colour swift

查看:96
本文介绍了更改导航控制器颜色迅速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将导航栏色调控制器颜色更改为颜色:R:73,G:155,B:255,A:0.7

I want to change the navigation bar tint controller colour to the colour: R: 73, G: 155, B: 255, A: 0.7

直到现在,我只能将其更改为系统中的颜色。以下是代理中的示例:

Till now, I have only been able to change it to the colours in the system. Here is an example in the Delegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

    UINavigationBar.appearance().barTintColor = UIColor.blueColor()
    UINavigationBar.appearance().tintColor = UIColor.whiteColor()

    return true
}

另外,我希望能够更改导航视图控制器标题颜色也是白色!

Also, I would like to be able to change the navigation view controller title colour to white too!

如果有可能我想将标签栏色调颜色改为R:73,G:155,B:255,A:0.7及其文本到白色。

If it is possible I want to change the tab bar tint colour to R: 73, G: 155, B: 255, A: 0.7 and their texts to white.

推荐答案

如果要设置导航栏的背景颜色:

If you want to set the background color of the nav bar:

UINavigationBar.appearance().barTintColor = UIColor.redColor()

注意RGB值从0.0到1.0,因此您必须将它们除以255,否则颜色将为白色。下一个色调:

Note RGB values are from 0.0 to 1.0 so you have to divide them by 255 or your color will just be white. Next tint:

UINavigationBar.appearance().tintColor = UIColor(red: 73.0 / 255.0, green: 155.0 / 255.0, blue: 255.0/ 255.0, alpha: 1.0)

然后设置标题文字:

UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: someColor, NSFontAttributeName: someFont]

最后是条形按钮项目:

UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: color, NSFontAttributeName: buttonFont], forState: UIControlState.Normal)

这篇关于更改导航控制器颜色迅速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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