我正在尝试更改内部的"后退"按钮UINavigationController
.这是我到目前为止尝试的和输出:
1
代码内 ViewDidLoad
self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "navBarBackButton") self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "navBarBackButton") self.navigationItem.backBarButtonItem?.image = UIImage(named: "navBarBackButton")
输出:
我尝试添加以下但id没有帮助:
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.Plain, target:nil, action:nil)
2
代码内 AppDelegate
let backImg: UIImage = UIImage(named: "navBarBackButton")! UIBarButtonItem.appearance().setBackButtonBackgroundImage(backImg, forState: .Normal, barMetrics: .Default)
输出:
3
我尝试添加后退按钮,Storyboard
但没有任何改变
4 - 感谢sanandiya vipul.还需要它而不是'后退'.这只会删除'返回但保持图像右下方而不是整个'
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -80.0), forBarMetrics: .Default)
这是输出:
这是我希望实现的结果
在Code下面添加ViewDidLoad方法.它为你工作很好.
对斯威夫特来说
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0,-80.0),forBarMetrics:.Default)
for Objective-c
[[UIBarButtonItem外观] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, - 80.f)forBarMetrics:UIBarMetricsDefault];