有很多时候,我们需要用到导航,那么更换导航的时候,是在那用那修改,还是自定义一个导航,或者是声明一个代理方法,经过查资料和对导航属性的一些了解,用一种方法最为简单,就是在入口类里面添加一个方法,调用偏移量的方法,达到隐藏默认导航按钮的效果,代码如下:

- (void)setNaviBack{
 UIFont *font = [UIFont systemFontOfSize:16.f];
    //title的颜色和字体大小
    NSDictionary *textAttributes = @{
                                     
                                     NSFontAttributeName : font,
                                     
                                     NSForegroundColorAttributeName : [UIColor whiteColor]
                                     
                                     };
    
    
    UINavigationBar * navigationBar = [UINavigationBar appearance];
    navigationBar.titleTextAttributes = textAttributes;
    //导航栏的背景颜色
    navigationBar.barTintColor = MainColor; //返回按钮的箭头颜色 [navigationBar setTintColor:[UIColor colorWithRed:0.984 green:0.000 blue:0.235 alpha:1.000]]; //设置返回样式图片 UIImage *image = [UIImage imageNamed:@"返回"]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; navigationBar.backIndicatorImage = image; navigationBar.backIndicatorTransitionMaskImage = image; UIBarButtonItem *buttonItem = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]; //设置图片与文本的偏移量
UIOffset offset; offset.horizontal = - ; offset.vertical = - ; [buttonItem setBackButtonTitlePositionAdjustment:offset forBarMetrics:UIBarMetricsDefault]; }

这样就可以了,每个页面的返回按钮都会被替换掉,效果如下:

最新文章

  1. 如何在ubuntu里面关掉后台的meteor
  2. html5的发展历程和由此引起的政治斗争
  3. bootstrap之消息提示
  4. Android之下拉刷新,上啦加载的实现(一)
  5. Poj 1054 The Troublesome Frog / OpenJudge 2812 恼人的青蛙
  6. Bzoj 1901: Zju2112 Dynamic Rankings 树套树,线段树,平衡树,Treap
  7. Eclipse Maven Project
  8. System.AccessViolationException: 尝试读取或写入受保护的内存 解决办法
  9. jq 22 一个很好图片显示
  10. Flask-WTF 配置、验证及日志P4
  11. parted分区和挂载及非交互式操作
  12. 使用 nodeJs 开发微信公众号(设置自动回复消息)
  13. skynet记录7:第一个服务logger和第二个服务bootstrap
  14. spring profile
  15. intellij error updating changes svn解决办法
  16. java并发基础
  17. from __future__ import print_function的作用
  18. Effective C++ 随笔(1)
  19. ELK学习笔记之ELK架构与介绍
  20. deepin下安装python的Tkinter库

热门文章

  1. NowCoderG:最大平方数
  2. NPOI workbook.RemoveSheetAt(0); 删除sheet页 次序 sheettmpRequire.CopySheet("Require", true);
  3. WEP无线网络密码破解
  4. Lintcode---翻转二叉树
  5. Vim-复制选中内容至系统剪贴板,光标移动到指定行的行首和行尾
  6. removeFromParentAndCleanup和callfuncN_selector
  7. yii2中的资源....
  8. 工作流Activiti的学习总结(十二) activiti官方十分钟快速学习 (zhuan)
  9. 【转】在MAC下配置MySQL 5.7 数据库的编码问题
  10. inline函数出现 undefined reference 错误