iOS - 更改UIBarButtonItem的高度 [英] iOS - Changing UIBarButtonItem's height

查看:216
本文介绍了iOS - 更改UIBarButtonItem的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIToolbar有一个很好的调整大小的选项(self.navigationController.toolbar.frame)我想知道是否有人知道如何改变UIBarButtonItem的高度?



<我有一个高度为117像素的自定义工具栏,到目前为止我还没有找到修改工具栏上按钮的方法。此外,我需要它作为工具栏,因为显示的视图覆盖了另一个动画视图(剪切场景样式),而我在第一个视图中设置资源,工具栏需要在所有它期间保持在顶部。

解决方案

我实际上遇到过这个问题,我唯一能想到的就是利用initWithCustomView并传入一个带有定义框架的UIButton。 / p>

  UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; 

/ *
*插入按钮样式
* /

button.frame = CGRectMake(0,0,宽度,高度);

UIBarButtonItem * barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

否则UIBarButtonItem只有一个可以设置的width属性,但遗憾的是不是height属性。我用initWithCustomView做的另一件好事就是传入一个带有按钮的工具栏和其他东西,比如活动指示器。希望这会有所帮助。


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.

解决方案

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.

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

/*
* Insert button styling
*/

button.frame = CGRectMake(0, 0, width, height);

UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

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.

这篇关于iOS - 更改UIBarButtonItem的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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