博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UINavigationController 总结
阅读量:7171 次
发布时间:2019-06-29

本文共 1806 字,大约阅读时间需要 6 分钟。

hot3.png

一 . UINavigationBar

  1.获取 UINavigationBar 对象: [UINavigationBar appearance] ,可以通过该方法对全部 navigation 进行设置

  2.设置导航栏背景图片:[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"name"] forBarMetrics:UIBarMetricsDefault];

  3.设置标题字体:[UINavigationBar appearance].titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};

二 . UIBarButtonItem

  1.获取 UIBarButtonItem 对象: [UIBarButtonItem appearance] 可以通过该方法实现对 barButtonItem (即导航栏按钮)样式,显示字体进行设置 (同一 navigation 下全部)

  2.设置按钮的颜色,大小 : [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:13]} forState:UIControlStateNormal];

  3.设置导航栏渐变色(返回箭头白色) : [UIBarButtonItem appearance].tintColor = [UIColor whiteColor];

三 . 去除 navigation 下边黑线

//去掉导航栏黑线    [[UINavigationBar appearance]  setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

四 . 修改 backItem 为图片

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"common_nav_back"] imageWithAlignmentRectInsets:UIEdgeInsetsMake(0, 0, 0, -15)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];

图片进行处理,否则图片会被横向拉伸(imageWithAlignmentRectInsets 设置图片距离边的距离)

五 . 用自己的图片替换V型,可以设置图片的backIndicatorImagebackIndicatorTransitionMaskImage。如下代码所示:

[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"back_btn.png"]];[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back_btn.png"]];

 

转载于:https://my.oschina.net/AngeloTsui/blog/663320

你可能感兴趣的文章
linux系统开机流程
查看>>
python元组 (tuple,即常量数组)
查看>>
Google 全球 IP 地址库
查看>>
linux中oracle的安装
查看>>
测试文章2测试文章2测试文章2测试文章2测试文章2测试文章2
查看>>
程序员的出路在哪里?
查看>>
Zend Framework 2 中的EventManager的使用方法
查看>>
android ×××及问题
查看>>
rsyslog+loganalyzer+evtsys搭建集中式监控系统
查看>>
Zabbix通过SNMP监控HP服务器硬件信息
查看>>
版本控制之道——Git(一)
查看>>
WebView 避免内存泄露的方法
查看>>
如何学好JAVA,怎么学JAVA
查看>>
JDBC简单介绍一
查看>>
关于对象的自我赋值行为
查看>>
6.5版 Samba服务器搭建
查看>>
分享27个谷歌(Google)镜像
查看>>
读<王垠:一种新的操作系统设计>
查看>>
一、linux的基础常识
查看>>
数据挖掘是如何解决问题的
查看>>