Xcode 6.1使用相同的2x图像为iPhone 6和4s模拟器 [英] Xcode 6.1 using same 2x image for iPhone 6 and 4s simulator

查看:134
本文介绍了Xcode 6.1使用相同的2x图像为iPhone 6和4s模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用资产目录来存储图像。我的应用包含全屏教程页面。在iPhone的单个图像资产的images.xcassets下有4个版本。 1x,2x,Retina 4 2x和3x。

I'm using Asset Catalog for images. My app contains full screen tutorial pages. Under images.xcassets for a single image asset for iPhone there are 4 versions. 1x, 2x, Retina 4 2x and 3x.

我正在使用Xcode 6.1。当应用程序在4s模拟器上运行时,它使用2x版本的映像。 iPhone 6模拟器正在使用相同的图像。无论我是否将部署目标设置为7.1,8.0或8.1同样的事情发生。

I'm using Xcode 6.1. When the app is run on 4s simulator it uses 2x version of the image. Same image is being used for iPhone 6 simulator. No matter if I set Deployment Target to 7.1, 8.0 or 8.1 same thing happens.

我附上了一个解释问题的测试项目。如果你在模拟器中运行项目,iPhone 4s和iPhone 6都会显示2x版本的图像。

I've attached a test project explaining the issue. If you run the project in simulator, both iPhone 4s and iPhone 6 showing the 2x version image.

https://www.dropbox.com/s/8gon4czetkya485/AssetCatalogTest.zip?dl=0

如何使用资产目录轻松显示4s和6的不同图像?

How can I easily show different image for 4s and 6 using Asset Catalog?

推荐答案

它看起来像就像没有办法解决这个问题。我尝试从启动图像复制规则,资产目录使用启动图像使用的667h和736h子类型删除图像。

It looks like there is no way around this. I tried duplicating the rules from a launch image and the asset catalog drops images with the 667h and 736h subtypes used by launch images.

你认为这样可行但是它不会:

You'd think this would work but it doesn't:

{
  "images" : [
    {
      "idiom" : "iphone",
      "scale" : "2x",
      "filename" : "4.png"
    },
    {
      "idiom" : "iphone",
      "filename" : "6.png",
      "subtype" : "667h",
      "scale" : "2x"
    }
  ]
}

您最好的方法是老式的方法。使用test-667之类的名称为每个大小创建图像,并执行以下操作:

Your best approach is the old-fashioned way. Create images for each size with names like test-667 and do something like:

[UIImage imageNamed:[NSString stringWithFormat:@"test-%g", [[UIScreen mainScreen] bounds].size.height]]

这篇关于Xcode 6.1使用相同的2x图像为iPhone 6和4s模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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