横向iPhone中的UIBarButtonItem高度

too*_*fah 9 iphone uinavigationbar uibarbuttonitem uinavigationitem titleview

我在iPhone应用程序中有一个导航栏,其中包含自定义UIBarButtonItems:

UIBarButtonItem* homePersonButton = [[UIBarButtonItem alloc]
       initWithImage:[UIImage imageNamed:@"homePerson.png"]
               style:UIBarButtonItemStylePlain
              target:self action:@selector(showHomePerson)];
Run Code Online (Sandbox Code Playgroud)

homePerson.png是20 x 18.

它在纵向模式下看起来很不错,但在横向模式下,按钮上的20x18图像太高,看起来不太好.看起来iOS在标准按钮上做了一些工作,以便在更薄的导航栏中根据需要缩小图像.

处理这个问题的最佳方法是什么?

另一个例子是我在导航栏的titleView中有一个自定义按钮.我还需要它在应用程序旋转时缩小.

在此先感谢你能给我的任何指示!

Kev*_*hon 5

工具栏和导航栏图像的大小为20 x 20,因此当您提供的图像不符合这些尺寸时,您需要离开框架来调整图像大小/缩放图像,从而导致出现问题.将图像调整大小/缩放到20x20,图像在纵向和横向上都应该看起来正确.