iOS 导航栏文字隐藏和图标自定义

OC 版

// 设置导航栏返回的图标
// [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
   [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"xxx"]];
   [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage  imageNamed:@"xxx"]];

// 隐藏导航栏返回按钮的文字
   [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

swift 版

// 设置导航栏返回按钮的图标
// UINavigationBar.appearance().tintColor = UIColor.white
   UINavigationBar.appearance().backIndicatorImage = UIImage(named: "xxx")
   UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(named: "xxx")
// 隐藏导航栏返回按钮的文字
   UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: 0, vertical: -60), for: UIBarMetrics.default)

以上写在AppDelegate中

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我是一条虫 身着花花绿绿 却不为哪怕一撇的惊鸿 我是一条虫 一屈一伸的爬行 这不是三拜九叩 更不求佛祖的庇佑 我躬...
    小庄大少阅读 288评论 2 1
  • 第一种:1<=n,m<=1000,mod<=1e9,用杨辉三角做例题
    Gitfan阅读 629评论 0 0
  • 注意://代表注释,被注释的代码段将不会被执行 import Foundation print("1","2","...
    七叶5阅读 162评论 0 2