BackBarButton将无法显示正确的标题 [英] BackBarButton won't display correct title

查看:101
本文介绍了BackBarButton将无法显示正确的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将backButton设置为简单的<"像这样:

I am trying to set my backButton to a simple "<" like this:

self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.Plain, target:nil, action:nil)
print(self.navigationItem.backBarButtonItem?.title)

打印将显示",但是在模拟器上运行我的应用程序将始终显示先前VC的标题.

The printing will display "", but running my app on the simulator will always display the title of the previous VC.

尽管我测试了

 navigationController?.navigationBar.tintColor = UIColor(red:0.60, green:0.60, blue:0.60, alpha:1.0)

将更改按钮的颜色.

注意:

我正在从嵌入在UINavigationController中的UIViewController推动 只是一个UIViewController

I am pushing from a UIViewController embedded in a UINavigationController to just a UIViewController

推荐答案

您需要在整个应用中隐藏backbarbutton标题,对吗?

You need to hide the backbarbutton title through out your app,right?

  • 然后,这个技巧可能会帮助您实现目标.

  • Then this trick may help you in achieving that.

快捷键:

UIBarButtonItem.appearance().setTitlePositionAdjustment(UIOffsetMake(0, -100), forBarMetrics: UIBarMetrics.Default)

目标C:

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -100)
                                                 forBarMetrics:UIBarMetricsDefault];

在您的appdelegate didFinishLaunchingWithOptions中添加以上代码,我们将标题从框架中隐藏(隐藏):p.

Add the above code in your appdelegate didFinishLaunchingWithOptions,we are pushing the title out of the frame(hidden) :p.

结果:

这篇关于BackBarButton将无法显示正确的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆