且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在UINavigationBar [iOS 7]中编辑左,右UIBarButtonItem的空格

更新时间:2023-01-04 08:50:12

我也面临着这个问题。我也有感觉在 iOS 7 还有更多空间。我发现这大约是 10 点数。当我想要 LeftBarItemButton 从边缘开始时,我通常使用负空格。这对你也很有用。

I was also facing this problem. I also have feelings that in iOS 7 there is more space. And I figured out that this is about 10 points more. I usually use negative spaces when I want for LeftBarItemButton to start from the edge. This can be useful for you as well.

UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

negativeSpacer.width = -16; // it was -6 in iOS 6

[self.navigationItem setLeftBarButtonItems:@[negativeSpacer, requiredButton]; /* this will be the button which you actually need */] animated:NO];