简体   繁体   English

如何在Xcode 4.2下用不同的图形集开发iOS应用?

[英]How to develop iOS app with different sets of graphics under Xcode 4.2?

I have this app with one whole set of images, but I would like to add for example personalized set of graphics. 我的这个应用程序带有一整套图像,但是我想添加例如个性化的图形集。 Is there an easy way to organize and develop source code and not to get lost while switching between these sets of images? 是否有一种简单的方法来组织和开发源代码,而又不会在这些图像集之间切换时迷路?

One way I see it is to have on my hard drive two folders with graphics and before releasing replace in project current images with personalized set... is there a better way? 我看到的一种方法是,在硬盘驱动器上有两个带有图形的文件夹,并在发布具有个性化设置的项目当前图像中的替换之前...是否有更好的方法?

I'm using Xcode 4.2 and iOS 5.0 for this app. 我正在为此应用程序使用Xcode 4.2和iOS 5.0。

Probably the easiest and most reliable in terms of maintainance is to write your own image access function or marco, that is controlled in one place globally. 就维护而言,最简单,最可靠的方法可能就是编写您自己的图像访问功能或marco,该功能在全球范围内受到控制。 Then use this in all cases where you want to have the flexibility for differnt images for example like this. 然后,在所有想要灵活处理不同图像的情况下,例如使用这种方法。 I just got used to this way of assigning an image with stretchableImageWithLeftCapWidth because it adjusts the size nicely. 我只是习惯了用stretchableImageWithLeftCapWidth分配图像的这种方式,因为它可以很好地调整大小。

Of course you may use any other way to assign your images, like directly without use of stretchableImageWithLeftCapWidth 当然,您可以使用任何其他方式来分配图像,例如直接使用而不使用stretchableImageWithLeftCapWidth

Anyway, this is my suggestion: 无论如何,这是我的建议:

   NSString *s = [NSString stringWithFormat:@"%s%i",@"imageName",CONST_VERSION];
   UIImage *theImage = [UIImage imageNamed:s];
   myImageView.image = [theImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];

and you can do 你可以做

 #define CONST_VERSION 1 // or 2

Then name your images like: 然后将您的图片命名为:

myImage1.png 

and

myImage2.png

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

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