问题描述
我想做的是改变后退按钮的高度。但是,据我所知,改变的唯一选择是宽度。所以,我想我会创建一个带有我自己的小图像的自定义后退按钮。现在我使用viewDidLoad方法完成了这个,代码如下:
What I'd like to do is alter the height of the back button. However, as I understand it, the only option to alter is width. So, I thought I'd create a custom back button with my own, smaller, image. Now I've done this using the viewDidLoad method with the code below:
//Setup navigation bar
navigationController?.navigationItem.backBarButtonItem = UIBarButtonItem(image:UIImage(named:"back_arrow.png"), style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
navigationController?.navigationItem.backBarButtonItem!.title = ""
然而,后退按钮保持蓝色,大,并且标题为后退。如何才能使此代码正常工作?调试器说它正在运行,但它没有改变任何东西。
However, the back button remains blue, large, and has the title 'Back'. How can I get this code to work properly? The debugger says it is running, but it is not changing anything.
推荐答案
对于颜色你必须在navBar上设置色调颜色,您也可以将 navigationItem.backBarButtonItem
设置为 nil
并使用 leftbarButtonItem
使用自定义按钮图像。
For color you have to set the tint color on navBar, also you can set navigationItem.backBarButtonItem
to nil
and use leftbarButtonItem
with custom button image.
这篇关于自定义后退按钮与图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!