【发布时间】:2010-11-09 21:34:39
【问题描述】:
我在 iPhone 应用中有一个导航栏,其中包含自定义 UIBarButtonItems:
UIBarButtonItem* homePersonButton = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"homePerson.png"]
style:UIBarButtonItemStylePlain
target:self action:@selector(showHomePerson)];
homePerson.png 为 20 x 18。
在纵向模式下看起来不错,但在横向模式下,按钮上的 20x18 图像太高了,看起来不好看。看起来 iOS 在其标准按钮上做了一些工作,以便在图像位于较细的导航栏中时根据需要缩小图像。
处理这个问题的最佳方法是什么?
另一个例子是当我在导航栏的 titleView 中有一个自定义按钮时。当应用旋转时,我也需要它缩小。
提前感谢您能给我的任何指点!
【问题讨论】:
-
hint 适用于 iOS5 用户。现在有一个 [[UIBarButtonItem alloc] initWithImage: LandscapeImagePhone:... 方法。
-
我的项目位于导航栏中,因此它们的样式始终为 UIBarButtonItemStyleBordered,除非我使用自定义视图创建它们。在这种情况下,我的自定义视图是否也可以作为系统项调整为 18x18 像素?
标签: iphone uinavigationbar uibarbuttonitem uinavigationitem titleview