Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 更改uibarbuttonite的宽度_Objective C_Ios_Width_Uibarbuttonitem - Fatal编程技术网

Objective c 更改uibarbuttonite的宽度

Objective c 更改uibarbuttonite的宽度,objective-c,ios,width,uibarbuttonitem,Objective C,Ios,Width,Uibarbuttonitem,如何将UIBarButtonItem的宽度更改为29px?属性宽度不起作用,我不想创建ui按钮并使用initWithCustomView,因为我希望方形背景调整为导航栏的颜色。 我正在使用initWithImage来初始化UIBarButtonItem 这是我的按钮,当前宽度为37像素。我想设置为29px 你不能。如果您想要自定义宽度,则需要使用initWithCustomView您可以通过从界面生成器将图像拖放到条形按钮项并使用以下代码更改自定义视图的宽度来实现: CGRect frame =

如何将
UIBarButtonItem
的宽度更改为29px?属性宽度不起作用,我不想创建
ui按钮
并使用
initWithCustomView
,因为我希望方形背景调整为导航栏的颜色。 我正在使用
initWithImage
来初始化
UIBarButtonItem

这是我的按钮,当前宽度为37像素。我想设置为29px


你不能。如果您想要自定义宽度,则需要使用
initWithCustomView

您可以通过从界面生成器将图像拖放到条形按钮项并使用以下代码更改自定义视图的宽度来实现:

CGRect frame = self.navigationItem.leftBarButtonItem.customView.frame;
frame.size.width = 141;
self.navigationItem.leftBarButtonItem.customView.frame = frame;

但是为什么它们在uiBarButtonim类中具有属性宽度?只有在按钮处于UIToolbar@MaxMacLeod询问者特别不想使用initWithCustomView。。。