ios 11导航栏替换返回按钮图片,隐藏文字
2018-01-26 14:20 dengchaojie_learner 阅读(3114) 评论(0) 编辑 收藏 举报//亲测成功,关键设置UIOffsetMake(-200, -10),在竖直方向上的偏移值,你也可以自己稍微调整一下,根据自己返回按钮图片大小;
if (IOS11_OR_LATER) {// 如果iOS 11走else的代码,系统自己的文字和箭头会出来
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-200, -10) forBarMetrics:UIBarMetricsDefault];
UIImage *backButtonImage = [[UIImage imageNamed:@"return_image"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[UINavigationBar appearance].backIndicatorImage = backButtonImage;
[UINavigationBar appearance].backIndicatorTransitionMaskImage =backButtonImage;
}else
{
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-200, 0) forBarMetrics:UIBarMetricsDefault];
UIImage *image = [[UIImage imageNamed:@"return_image"] imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[image resizableImageWithCapInsets:UIEdgeInsetsMake(0, image.size.width, 0, 0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}
https://stackoverflow.com/questions/46193204/custom-back-indicator-image-and-ios-11
// 大标题
self.navigationController.navigationBar.prefersLargeTitles = true;
/** iPhone 6机型适配方案 高度*/
#define kHeightAdapter6 (screenHeight == 812.0 ? 667.0/667.0 : screenHeight/667.0)
/** iPhone X 安全区 导航栏 高度*/
#define SafeAreaTopHeight (screenHeight == 812.0 ? 88 : 64)
/** iPhone X 安全区 底部 高度*/
#define SafeAreaBottomHeight (screenHeight == 812.0 ? 34 : 0)
/** 是否是 iPhone X */
#define IS_IPHONEX (screenHeight == 812.0 ? YES : NO)