[英]Where do I put image for appcelerator ios?
我正在使用Appcelerator Titan将我的Android应用程序移植到ios。
如果我定义用于视图或类似的图像
backgroundImage : "/images/blueButton.png",
我要放置blueButton.png的文件位置在哪里?
是/resources/iphone
, /resources/images
还是其他?
根据Malcolm Hollingsworth在归档的Appcelerator论坛上的以下回答 :
设备特定的图像应放置在android特定图像的android文件夹内,iOS图像(iPhone,iPod和iPad)的iphone应放置在其中。
如果要创建一个同时支持两个主要平台的应用程序,并且无论设备(例如照片)都支持某些图像,则可以并且应该在设备文件夹之外创建一个文件夹。
在此示例中:
现在,在支持所有图像密度(或至少主要密度)的跨平台应用程序中,您的文件夹看起来像这样,其中包含图像;
/resources/ /resources/android/ /resources/android/images/res-ldpi/test1.png /resources/android/images/res-mdpi/test1.png /resources/android/images/res-hdpi/test1.png /resources/android/images/res-xhdpi/test1.png /resources/iphone/ /resources/iphone/images/test1.png /resources/iphone/images/test1@2x.png
有了这两个
/resources/iphone/images/test1.png = non-retina /resources/iphone/images/test1@2x.png = retina
...
然后您的代码将是;
var myImageView = Ti.UI.createImageView({ height: Ti.UI.SIZE, image : '/images/test1.png', width: Ti.UI.SIZE });
给马尔科姆·霍林斯沃思的小费。
对于iOS,将图片放在“ / resources / images”路径中,应该可以正常工作。 对于iOS,资源文件夹中的非视网膜显示图像名称应该是正常的(在下面的示例中为myImage.png),对于资源文件夹中的视网膜显示图像名称应该是myImage@2x.png,其大小比非视网膜图像大一倍。
对于Android设备,将图像放在“ resources / android / images /”路径中的设备专用文件夹中,应该可以正常工作。
var myImage = Titanium.UI.createImageView({
height : Titanium.UI.SIZE,
width : Titanium.UI.SIZE,
image : "/images/myImage.png"
});
此代码对于android和iOS都可以正常工作。
注意:在iOS中,您可以直接将图像放置在iPhone文件夹中,并在createImageView中使用图像:“ myImage.png”作为参数,但是在android中将无法使用。 因此最好使用上面的文件夹结构,在iOS和Android中使用相同的图像。 您可以将特定于设备的图像直接放置在iPhone文件夹中,因为它们永远不会在android设备中使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.