答案 0 :(得分:1)
再添加一行:
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics: .Default)
通过这种方式使用自定义按钮为条形按钮设置图像的另一种方法是:
let button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
button.setImage(UIImage(named: "GoBack"), forState: UIControlState.Normal)
button.addTarget(self, action: "backButtonPressed:", forControlEvents: UIControlEvents.TouchUpInside)
button.frame = CGRectMake(0, 0, 53, 31) // set this as per your need.
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.leftBarButtonItem = barButton
它的助手方法:
func backButtonPressed(sender:UIButton) {
navigationController?.popViewControllerAnimated(true)
}