之前都是用这个方法来隐藏返回按钮的文字的,
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
forBarMetrics:UIBarMetricsDefault];
但是到iOS11这个方法已经不行了,视图的位置会乱掉,后面在stackflow找到了一个办法,还挺好用的,
UIBarButtonItem *navBarButtonAppearance = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];
[navBarButtonAppearance setTitleTextAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:0.1],
NSForegroundColorAttributeName: [UIColor clearColor] }
forState:UIControlStateNormal];
网友评论