简体   繁体   English

XCode iOS模拟器 - 应用程序是像素化的

[英]XCode iOS simulator - application is pixelated

I'm a beginner with XCode and I've encountered an issue. 我是XCode的初学者,我遇到了一个问题。 When I build my application, it looks fine in the standard iPhone simulator, but when I change the hardware to a retina device, the UI elements of my application become pixelated. 当我构建我的应用程序时,它在标准iPhone模拟器中看起来很好,但是当我将硬件更改为视网膜设备时,我的应用程序的UI元素变得像素化。 How can I fix this? 我怎样才能解决这个问题?

You're seeing that because the retina screen is stretching the image you're supplying across more points on the screen. 你看到了这一点,因为视网膜屏幕正在拉伸你在屏幕上更多点提供的图像。 You can supply hi-res images in your bundle by appending @2x to the filename 您可以通过在文件名后附加@2x来提供捆绑包中的高分辨率图像

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html : "If you load an image from a file whose name includes the @2x modifier, the scale is set to 2.0. You can also specify an explicit scale factor when initializing an image from a Core Graphics image. All other images are assumed to have a scale factor of 1.0. " http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html :“如果从名称中包含@ 2x修饰符的文件加载图像,则会设置比例从Core Graphics图像初始化图像时,您还可以指定显式比例因子。假设所有其他图像的比例因子为1.0。

Here's a guide to supporting high-resolution screens . 这是支持高分辨率屏幕指南

As @RobotWoods mentioned, all images in your app need to have @2x versions. 正如@RobotWoods所提到的,您应用中的所有图片都需要@2x版本。

If you're using OpenGL ES, custom code that creates images, or core animation, you need to make sure your code accounts for the display's scale. 如果您正在使用OpenGL ES,创建图像的自定义代码或核心动画,则需要确保您的代码考虑到显示的比例。

If you're using only standard UIKit elements like UIButton, UILabel, UITableView, etc. then all you need to do is provide the @2x images. 如果您只使用UIButton,UILabel,UITableView等标准UIKit元素,那么您需要做的就是提供@2x图像。

If that doesn't help, please post screenshots and relevant code of what looks blurry. 如果这没有帮助,请发布截图和相关代码看起来模糊。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM