我有一个 UIViewController
设置为在其 UINavigationItem
右侧显示一个信息按钮,如下所示:
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(toggleAboutView) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease];
效果很好,但唯一的问题是按钮右侧几乎没有空间,看起来很丑:
有没有办法让按钮从右侧移出约5 px?
谢谢。
最佳答案
infoButton.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 10);
关于iphone - rightBarButtonItem 信息按钮,右侧没有空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3692057/