美文网首页iOS Developer
iOS 导航栏文字隐藏和图标自定义

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

作者: FreeLeaves | 来源:发表于2016-12-16 20:28 被阅读0次

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中

相关文章

网友评论

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

    本文链接:https://www.haomeiwen.com/subject/jbonmttx.html