iOS隐藏系统导航栏左侧返回按钮上的标题

   iOS开发中当使用系统导航栏时,默认左侧显示返回按钮,标题为上一级界面的标题,以下为去掉导航栏左侧返回按钮上标题的方法:

1、方法一

 NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
    [UIFont systemFontOfSize:0.0001],NSFontAttributeName,nil];
    [[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
注:当上一级标题内容很长时,下一级界面标题仍能够居中显示。
其他负面影响,有待于测试。

2、方法二

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin,NSIntegerMin)forBarMetrics:UIBarMetricsDefault];
缺点:当上一级标题内容很长时,下一级界面标题不能够居中显示。

猜你喜欢

转载自blog.csdn.net/xuhen/article/details/77235264