iphone - 如何在 iphone 应用程序中将导航 Controller 的后退按钮与其左角对齐

标签 iphone ios uinavigationcontroller uinavigationbar customization

我通过向其添加图像自定义了我的导航 Controller 后退按钮,但我仍然无法将后退按钮置于导航栏的左角。我想避免导航栏的左边距和后退按钮之间的间隙或空间。 感谢您的帮助。

最佳答案

这是你可以使用的代码

 UIButton* backButton= [UIButton buttonWithType:UIButtonTypeCustom];
//here in below you just need to pass the point where you want to place your 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;

希望对您有所帮助。

关于iphone - 如何在 iphone 应用程序中将导航 Controller 的后退按钮与其左角对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13402395/

相关文章:

iphone - UITableView中的UILabel设置大小

iphone - SDWebImage清除缓存

iphone - NSDecimalNumber 和从末尾弹出数字

iphone - 如何使用 Xcode 4 和 OCUnit 运行应用程序测试?

ios - 将数据(标签和日期选择器)从我的应用程序发送到提醒应用程序

iphone - 如何使黑色 UISegmentedControl 显示为可见的选择突出显示?

iphone - 修饰 UIImageView 的内部

objective-c - 自动旋转 iOS 8 导航 Controller

ios - navigationController popToViewController 无法在 swift 3 中工作

iphone - 隐藏 UI 导航栏中的后退按钮