简体   繁体   English

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

[英]How to align back button of the navigation controller to its left corner in iphone application

I have customized my navigation controller back button by adding image to it,but still I couldn't get back button in to navigationbar's left corner.I want to avoid the gap or the space between navigation bar's left margin and the backbutton. 我已经通过向其添加图像来自定义导航控制器的后退按钮,但仍然无法将后退按钮插入到导航栏的左角。我想避免导航栏左边缘和后退按钮之间的间隙或空间。 Thanks for the help. 谢谢您的帮助。

Here is the code you can use 这是您可以使用的代码

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

As you said you need space between navigation bar's left margin and the back button. 如您所说space between navigation bar's left margin and the back 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;

I hope it may help you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM