【问题标题】:IPhone development: Background Image for UIView seems at the double resolution in the IOS SimulatoriPhone 开发:UIView 的背景图像在 IOS 模拟器中似乎是双倍分辨率
【发布时间】:2012-12-19 09:44:54
【问题描述】:

我正在从事我在IPhone development: How to build a custom view hierarchy? 中描述的项目。我仍在努力解决我在该主题中描述的问题,同时我尝试做一些有意义的事情。

我需要在第一个视图中打印背景图像,并在我的 _MyAppName_ViewController.m 类中编写了以下代码:

self.backGroundImage = [UIImage imageNamed:@"giris.jpg"];
self.view.backgroundColor = [UIColor colorWithPatternImage:self.backGroundImage];

backGroundImage 是我在头文件中声明的一个属性,类型为 UIImage。 giris.jpg 是大小为 640x960 的图像,但我在模拟器中看到的是图像的左上角 320x480 大小的部分。我尝试将 IOS 模拟器设备类型从 iPhone 更改为 iPhone(Retina 3.5 英寸)和 iPhone(Retina 4.0 英寸),但我得到了相同的结果。代码中是否缺少某些内容?

【问题讨论】:

  • 这是因为您将“点”与“像素”混淆了。您的 giris.jpg 应该是 320x480,并且您的 App Bundle 中还应该有一个 giris@2x.jpg。然后 UIKit 会为你选择合适的。

标签: iphone objective-c xcode ios5 uiview


【解决方案1】:

请确保您包含正确的非视网膜和视网膜图像尺寸分别为 320x480 和 640x960。问题是 giris.jpg 的大小为 640x960,因其名称而被视为非视网膜。

对于非视网膜 - 320x480 - giris.jpg 对于视网膜 - 640x960 - giris@2x.jpg

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-01
    • 2016-06-28
    • 2015-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-25
    相关资源
    最近更新 更多