如何将UIBarButtonItem
的宽度更改为29px?属性宽度不起作用,我不想创建UIButton
并使用initWithCustomView
,因为我想让方形背景适应导航栏的颜色。 我正在使用initWithImage
来初始化UIBarButtonItem
。更改UIBarButtonItem的宽度
这是我的按钮,当前宽度为37px。我想设置为29px。
如何将UIBarButtonItem
的宽度更改为29px?属性宽度不起作用,我不想创建UIButton
并使用initWithCustomView
,因为我想让方形背景适应导航栏的颜色。 我正在使用initWithImage
来初始化UIBarButtonItem
。更改UIBarButtonItem的宽度
这是我的按钮,当前宽度为37px。我想设置为29px。
你不能。如果你想定制的宽度,你将需要使用initWithCustomView
但是他们为什么在UIBarButtonItem类中有属性宽度? – gnclmorais 2011-12-28 10:02:33
只有在UIToolbar中有按钮时才能使用它 – RolandasR 2011-12-28 10:36:57
您可以将图像从界面生成器拖放到栏按钮项目并更改自定义视图的宽度与此代码做到这一点:
CGRect frame = self.navigationItem.leftBarButtonItem.customView.frame;
frame.size.width = 141;
self.navigationItem.leftBarButtonItem.customView.frame = frame;
@MaxMacLeod提问者明确不想使用initWithCustomView ... – 2013-07-21 02:36:25