在 Cocoa Touch 中更改 NavigationBar 和 UIBarButtonItem 元素的高度 [英] Change the height of NavigationBar and UIBarButtonItem elements inside it in Cocoa Touch

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

问题描述

我想这并不完全符合 Apple 的指导方针,但我想它一定是有可能的.我想更改 UINavigationController 内导航栏的高度和该栏内 UIBarButtonItem 元素的高度.

I suppose it's not strictly in line with Apple guidelines but I guess it must be possible somehow. I'd like to change the height of navigation bar inside UINavigationController and the height of UIBarButtonItem elements inside that bar.

使用 this question 中的技巧,我设法改变了导航栏的高度但我看不到调整条形按钮项目高度的方法.

Using a trick from this question I managed to change the height of navigation bar but I can see no way of adjusting the height of bar button items.

如果有人知道如何更改条形按钮项目的大小,请帮助我.

If anyone knows how to change the size of bar button items, please help me out.

推荐答案

也许这个关于自定义导航栏的教程会对你有所帮助:重建 iBooks 木质主题导航栏

Maybe this tutorial about a customized navbar will help you: Recreating the iBooks wood themed navigation bar

如果你用 UIImageView 创建一个 BarButtonItem 你也许可以改变自定义 UIImageView 的 framesize/boundsize

If you create a BarButtonItem with a UIImageView you can maybe change the framesize/boundsize of the custom UIImageView

UIImageView* imageView = [[[UIImageView alloc] initWithFrame:navigationController.navigationBar.frame] autorelease];
imageView.contentMode = UIViewContentModeLeft;
imageView.image = [UIImage imageNamed:@"NavBar-iPhone.png"];
[navigationController.navigationBar insertSubview:imageView atIndex:0];

因此,根据您的需要,您可以为 -initWithFrame 方法提供适当的值.

So for your need you would give the -initWithFrame method appropriate values.

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

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