对于中的后退按钮UINavigationBar
,如果添加图像,它将仅在后按钮的中心显示图像。您也不能在其中添加图像。因此,不要这样做,而是隐藏您的backbutton
代码并在您的方法中添加此代码viewDidload
以为其添加图像,看起来就像您需要的那样。
self.navigationItem.hidesBackButton = YES;
UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:@"back_normal"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"back_pressed"] forState:UIControlStateSelected];
[button addTarget: nil action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0, 0, 50, 30);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: button];