如何在iPhone应用程序中将导航控制器的后退按钮对齐到左下角

时间:2012-11-15 16:54:25

标签: iphone ios uinavigationcontroller uinavigationbar customization

我已经通过添加图像来定制我的导航控制器后退按钮,但仍然无法将按钮返回到导航栏的左角。我想避免导航栏的左边距和后退按钮之间的间隙或空间。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

以下是您可以使用的代码

 UIButton* backButton= [UIButton buttonWithType:UIButtonTypeCustom];
//here in below you just need to pass the point where you want to place your button.

如你所说,你需要space between navigation bar's left margin and the back button.

[backButton setFrame:CGRectMake(xOrigin, yOrigin, width, height)];
[backButton setImage:[UIImage imageNamed:@"imageName.png"] forState:UIControlStateNormal];
UIBarButtonItem * leftBarButton =[[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem= leftBarButton;

我希望它可以帮助你。