设置导航标题颜色以及导航条背景色
生活随笔
收集整理的這篇文章主要介紹了
设置导航标题颜色以及导航条背景色
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
//設(shè)置導(dǎo)航條標(biāo)題顏色
[self.navigationController.navigationBar setTitleTextAttributes: @{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];//或者自定義標(biāo)題,新建一個(gè)lable賦給self.navigationItem.titleView?
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];titleLabel.backgroundColor = [CommonTools colorWithHexString:@"1680fa" alpha:1.0];titleLabel.font = [UIFont boldSystemFontOfSize:20];titleLabel.textColor = [UIColor whiteColor];titleLabel.textAlignment = NSTextAlignmentCenter;titleLabel.text = @"視頻聊天";self.navigationItem.titleView = titleLabel;
//設(shè)置導(dǎo)航欄背景色
self.navigationController.navigationBar.barTintColor = [CommonTools colorWithHexString:@"1680fa" alpha:1.0]; colorWithHexString:@"1680fa" alpha:1.0取到的顏色接近于導(dǎo)航條 + (UIColor *)colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha {unsigned int red, green, blue;NSRange range;range.length =2;range.location =0;[[NSScanner scannerWithString:[hexString substringWithRange:range]]scanHexInt:&red];range.location =2;[[NSScanner scannerWithString:[hexString substringWithRange:range]]scanHexInt:&green];range.location =4;[[NSScanner scannerWithString:[hexString substringWithRange:range]]scanHexInt:&blue];return [UIColor colorWithRed:(float)(red/255.0f)green:(float)(green/255.0f)blue:(float)(blue/255.0f)alpha:alpha]; }
總結(jié)
以上是生活随笔為你收集整理的设置导航标题颜色以及导航条背景色的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 豆瓣电台WP7客户端 开发记录1
- 下一篇: 精密单点定位(PPP)数据处理反演潮汐(