导航栏

1.状态栏的颜色

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;

2.导航栏的颜色

self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];

3.返回按钮的颜色

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

4.去掉导航栏下面的分割线

[self.navigationController.navigationBar setBackgroundImage:[self GetImageWithColor:MainColor andHeight:64*MyHeight] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[self GetImageWithColor:MainColor andHeight:1]];

5.设置导航栏Title的颜色和字体

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:SLLFont(18),NSForegroundColorAttributeName:[UIColor whiteColor]}];

6.修改返回按钮的样式,去掉“back”,在AppDelegate中设置

[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];

7.根据颜色生成图片

- (UIImage*)GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height
{
    CGRect r= CGRectMake(0.0f, 0.0f, 1.0f, height);
    UIGraphicsBeginImageContext(r.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, r);
    
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return img;
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容