iOS - 更改 UIBarButtonItem 的高度
UIToolbar 有一个很好的调整大小选项(self.navigationController.toolbar.frame) 我想知道是否有人知道更改 UIBarButtonItem 高度的方法?
我有一个高度为 117 像素的自定义工具栏,到目前为止我还没有找到修改工具栏上按钮的方法。另外,我需要它作为工具栏,因为当我在第一个视图中设置资源时,显示的视图被另一个动画视图(剪切场景样式)覆盖,并且工具栏需要在整个过程中保持在顶部。
UIToolbar has a nice option for resizing (self.navigationController.toolbar.frame) I'm wondering if anyone knows of a way to change the height of a UIBarButtonItem?
I have a custom toolbar with a height of 117 pixels and so far I haven't found a way of modifying the buttons on the toolbar. Also I need it to be a toolbar because the displayed view gets covered with another animated view (cut scene style) while I setup assets in the first view and the toolbar needs to stay on top during all of it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上我自己也遇到过这个问题,我唯一能想到的就是利用 initWithCustomView 并传入一个带有定义框架的 UIButton 。
否则 UIBarButtonItem 只有一个可以设置的宽度属性,但不幸的是没有高度属性。我用 initWithCustomView 做的另一件漂亮的事情是传递一个带有按钮和其他东西(如活动指示器)的工具栏。希望这有帮助。
I've actually run into this myself and the only thing I could come up with was leveraging initWithCustomView and passing in a UIButton with a defined frame.
Otherwise UIBarButtonItem only has a width property that can be set but unfortunately not a height property. Another nifty thing I've done with initWithCustomView is to pass in a toolbar with a button and other things like activity indicators. Hope this helps.
使用您喜欢的框架、图像、目标和选择器等创建一个
UIButton
,然后使用UIBarButtonItem
的initWithCustomView:
方法并将 UIButton 用作自定义视图。create a
UIButton
with your preferred frame and image and target and selector and etc. then useUIBarButtonItem
'sinitWithCustomView:
method and use the UIButton as the customView.让这个简单的三个步骤
1 编写属性:
2 综合:
3 编写实现:
现在,当您在 uibarbuttomitem 上有 uibutton 时,您可以为 uibutton 定义所有属性,例如图像、操作等。
Make this simple three steps
1 Write property:
2 Synthesize:
3 Write implementation:
Now when you have uibutton on uibarbuttomitem you can define all property for uibutton like, image, action etc.