In iOS App development, application size plays a major role in the success of the application. Size always matters a lot whether it is game or utility app.

Recently, apple has launched  many devices like iPhone 6, 6+, iPad Air and lot more coming soon. And because of this, resolution of the image increases undoubtedly and so the app size. This is the hazardous problem and so we need to find the solution which can help to decrease the app size & improve the performance as well.

There are many optimal solutions, but one of it is to use SpriteSheet into Utility apps development. If you really want to use and improve app size & performance, this tutorial will definitely give you a right way to do so.

Think about the case where you are working on any application which has  many images used in the app. Now instead of using that images directly into app, you can use SpriteSheet.

In some cases; when we are making cocos2d games, we required to use utility controls to create  simple layouts. At that time we need to use the UIImage from SpriteSheet image set. This can prove to be a very helpful tool.

Here are some steps you need to follow :

  1. First get the Zwoptex from here: & install it if you have already get it.
  2. To create SpriteSheet you just need to create new sheet & drag all images in that. (For more check this:
  3. You need to have cocos2d library added in your application
  4. Once you are done will all steps, here is some lines of code that will make the trick.




[code language=”objc”]- (UIImage *) imageFromSprite :(CCSprite *)sprite{
int tx = sprite.contentSize.width;
int ty = sprite.contentSize.height;
CCRenderTexture *renderer = [CCRenderTexture renderTextureWithWidth:tx height:ty];
sprite.anchorPoint = CGPointZero;[renderer begin];[sprite visit];[renderer end];
return [renderer getUIImage];

How To Use Above Method?


To use above method simply write this line:

[code language=”objc”] CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:@”TestImage.png”];
UIImage *Image = [self imageFromSprite:sprite];[/code]

That’s It. Happy Coding 🙂 !

Tags: app, CCSprite, iOS, SpriteSheet, UIImage, Utility Apps Development