1、状态栏(statusBar)

  • 默认:黑色
  • 改变为白色:
  • 1.1 第一步:

    1. info.plist中添加View controller-based status bar appearanceNO
  • 1.2 第二步:

    1. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

2、导航栏的背景和文字Color:

  • 2.1 方法一:

    1. // 设置NavigationBar 背景颜色 & title 颜色
    2. [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:213/255.0 alpha:1.0]];
    3. [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
  • 2.2 方法二:

    1. // 设置NavigationBar背景颜色
    2. [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
    3. // @{}代表Dictionary
    4. [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

3、导航栏使用背景图片:

  1. [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bg.png"] forBarMetrics:UIBarMetricsDefault];

4、取消导航栏按钮Item图片被渲染的效果

  • 4.1 方法一:通过代码设置

    1. image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  • 4.2 方法二:通过Assets.xcassets设置

  • 找到对应图片的Image Set栏,Render as设置为Original Image.

5、导航栏标题的字体:

  1. UITextAttributeFont - 字体
  2. UITextAttributeTextColor - 文字颜色
  3. UITextAttributeTextShadowColor - 文字阴影颜色
  4. UITextAttributeTextShadowOffset - 偏移用于文本阴影
  5. NSShadow *shadow = [[NSShadow alloc] init];
  6. shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
  7. shadow.shadowOffset = CGSizeMake(0, 1);
  8. // 任意颜色、字体大小、文字阴影颜色
  9. [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, shadow, NSShadowAttributeName,
  10. [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil nil]];

6、图片作为导航栏标题:

  1. self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"appcoda-logo.png"]];

7、添加多个栏按钮项目:

  1. UIBarButtonItem *shareItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action: nil nil];
  2. UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action: nil nil];
  3. NSArray *itemsArr = @[shareItem,cameraItem];
  4. self.navigationItem.rightBarButtonItems = itemsArr;

8、自定义后退按钮的文字和颜色:

  • 8.1 方法一:

    1. UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    2. self.navigationItem.backBarButtonItem = item;
    3. [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    4. [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:19.0]}];
    5. self.title = [NSString stringWithFormat:@"第%lu页",(unsigned long)self.navigationController.viewControllers.count];
    6. //自定义返回按钮
    7. UIImage *backButtonImage = [[UIImage imageNamed:@"fanhui.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 30, 0, 0)];
    8. [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    9. //将返回按钮的文字position设置不在屏幕上显示
    10. [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];

iOS状态栏、导航栏的设置的更多相关文章

  1. iOS 11 导航栏 item 偏移问题 和 Swift 下 UIButton 设置 title、image 显示问题

    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...

  2. IOS 改变导航栏返回按钮的标题

    IOS 改变导航栏返回按钮的标题   下午又找到了一个新的方法 这个方法不错 暂时没有发现异常的地方. 新写的App中需要使用UINavigationController对各个页面进行导航,但由于第一 ...

  3. 导航栏视图设置 tabbleView 是设置总背景图

    //导航栏视图设置 tabbleView 是设置总背景图 //默认的时白色半透明(有点灰的感觉), UIBarStyleBlack,UIBarStyleBlackTranslucent ,UIBarS ...

  4. 获取不同机型微信小程序状态栏+导航栏高度

    获取不同机型微信小程序状态栏+导航栏高度 一. 前言 很多时候我们开发微信小程序,都需要先知道状态栏和导航栏的高度,才能去做其他功能 二. 获取微信小程序状态栏高度 用wx.getSystemInfo ...

  5. iOS 自定义导航栏 和状态栏

    一.更改状态栏颜色 (StatusBar) 就是比如导航栏是红色的状态栏是绿色的. 要实现这样的效果其实很简单,就是添加一个背景view. 简单的实现过程如下: 1 // 设置导航颜色 可用 2 [s ...

  6. 如何控制iOS的导航栏和状态栏的样式

    这是一个很常用的开发场景,就是改变导航栏上的文字颜色与背景色,如果你曾有 windows form 开发经验一定会笑我:"卧槽,这有什么好写的,不就是设置两个属性就可以了吗?" 我 ...

  7. ios隐藏导航栏底线条和导航、状态栏浙变色

    方法一遍历法: 在你需要隐藏的地方调用如下代码 [self findlineviw:self.navigationBar].hidden = YES; -(UIImageView*)findlinev ...

  8. IOS 导航栏属性设置

    IOS 7 以上系统导航栏: [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; // 返回按钮颜色 [UINaviga ...

  9. iOS 隐藏导航栏 隐藏状态栏

    1导航栏 self.navigationController.navigationBarHidden = YES; 2 状态栏 [[UIApplication sharedApplication] s ...

随机推荐

  1. sourcetree 安装与操作

    sourcetree操作 http://www.jianshu.com/p/be9f0484af9d SourceTree安装教程和GitLab配置详解 http://www.cnblogs.com/ ...

  2. Docker资源

    1.Docker入门教程 http://www.code123.cc/docs/docker-practice/repository/config.html 2.Docker入门教程 http://w ...

  3. php实现oracle操作

    <?php function Query($sql,$prms){ $db = " (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ...

  4. Resque基本

    原文:http://www.cnblogs.com/rywx/archive/2012/05/26/2519615.html Resque resque是基于redis的后台任务组件,能把任何类或模块 ...

  5. S2-045漏洞利用工具&解决方案

    简单的重复造一个轮子,漏洞危害蛮大的 影响版本:Struts 2.3.5 - Struts 2.3.31,Struts 2.5 - Struts 2.5.10 仅供学习测试使用,严禁非法操作! 下载链 ...

  6. ghld data format

    %CTF: 1.00%FileType: PROF strp "VelocityProfile"%PROFSpec: 1.00 2006 00 00%Manufacturer: C ...

  7. 安装zabbix-agent报错 Error: failure: repodata/primary.xml.gz from zabbix: [Errno 256] No more mirrors to try.

    安装zabbix-agent报错 yum install -y zabbix-agent Loaded plugins: fastestmirror, refresh-packagekit, secu ...

  8. git clone 某一特定分支<转>

    网上搜索自己想要的答案,往往会搜大一大堆感觉没用的,或者看不懂的东西, 最好终于找到了想要答案,特记录一下: ============================================= ...

  9. MongoDB数据导入hbase + 代码

    需求: 从mongoDB里面查出来数据,判断是否有该列簇,如果有则导入此条数据+列簇,如果没有,则该条数据不包含该列簇 直接贴出代码: package Test; import java.util.A ...

  10. python爬虫实战(1)--爬取糗事百科

    这里利用正则表达式进行匹配,糗事百科是不需要登录的,所以也没必要用到Cookie,另外糗事百科有的段子是附图的,我们把图抓下来图片不便于显示,那么我们就尝试过滤掉有图的段子. 本篇目标 1.抓取糗事百 ...