rightBarButtonItem信息按钮,右侧没有空格 [英] rightBarButtonItem info button, no space to the right

查看:156
本文介绍了rightBarButtonItem信息按钮,右侧没有空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 UIViewController 设置为在 UINavigationItem 右侧显示信息按钮,如下所示:

I have a UIViewController set up to display an info-button on the right in its UINavigationItem like this:

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(toggleAboutView) forControlEvents:UIControlEventTouchUpInside]; 
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease];

完美无缺,但唯一的问题是我留下的空间很小甚至没有按钮的右边,看起来很丑:

That works perfectly, but the only problem is that I'm left with little to no space to the right of the button, which looks pretty ugly:

按钮是否有任何方法可以从右侧移动约5 px?

Is there any way for the button to move about 5 px out from the right side?

谢谢。

推荐答案

infoButton.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 10);

这篇关于rightBarButtonItem信息按钮,右侧没有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆