gnc*_*ais 8 objective-c width uibarbuttonitem ios
如何将a的宽度更改UIBarButtonItem为29px?属性宽度不起作用,我不想创建UIButton并使用,initWithCustomView因为我希望方形背景调整为导航栏颜色.我正在使用initWithImage初始化UIBarButtonItem.
这是我的按钮,当前宽度为37px.我想设置为29px.

Rol*_*asR 16
你不能.如果您想要自定义宽度,则需要使用initWithCustomView
您可以通过从接口构建器将图像拖放到条形按钮项并使用以下代码更改自定义视图的宽度来执行此操作:
CGRect frame = self.navigationItem.leftBarButtonItem.customView.frame;
frame.size.width = 141;
self.navigationItem.leftBarButtonItem.customView.frame = frame;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11793 次 |
| 最近记录: |