setBackgroundImage forBarMetrics图像大小? [英] setBackgroundImage forBarMetrics image size?

查看:693
本文介绍了setBackgroundImage forBarMetrics图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS编程方面相当新,我正在创建我的第一个应用程序。
我一直在尝试使用以下代码来更改导航栏背景图片(这是使用新的iOS 5方法):

I am fairly new in iOS programming and I am creating my first app. I have been trying to use the following code to change the navigation bar background image (this is using the new iOS 5 method):

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"gradientBackgroundPlain.png"] forBarMetrics: UIBarMetricsDefault];

它工作正常,但我的图像是640 x 88,它看起来太大了吧。这就像系统不想扩展它,还是我需要手动完成?如果我缩放图像并创建一个较小的图像,它在视网膜显示中看起来像素化。

It works fine, but my image is 640 x 88 and it looks too big for the bar. It's like the system doesn't want to scale it, or do I need to do it manually? If I scale the image and create a smaller one it looks pixelated in the retina display.

对此有何想法?

任何帮助或回复都将不胜感激。

Any help or response will be appreciated.

谢谢,

Jorge .-

推荐答案

您的图像gradientBackgroundPlain.png应为320x44,并创建第二个图像,名为gradientBackgroundPlain@2x.png,大小为640x88。在捆绑包中包含@ 2x图像,但继续为图像名称指定gradientBackgroundPlain.png。平台会自动选择正确尺寸的图像,具体取决于是否存在视网膜显示。

Your image gradientBackgroundPlain.png should be 320x44, and create a second image named gradientBackgroundPlain@2x.png with a size of 640x88. Include the @2x image in your bundle, but continue to specify gradientBackgroundPlain.png for the name of the image. The platform automatically chooses the correct size image for use depending on whether there is a retina display present or not.

这篇关于setBackgroundImage forBarMetrics图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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