Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw selected areas of a UIImage

I have a UIImage containing an image with a whole bunch of smaller pictures on the image (essentially an image strip containing sprites). I'd like to draw a single sprite onto an area of my UIView.

I can't seem to find a way draw only part of the UIImage onto the view. Is there a method that does this?

like image 376
rein Avatar asked Oct 26 '09 21:10

rein


1 Answers

I think you may be looking for CGImageCreateWithImageInRect(). You can get a CGImage from a UIImage with the property of the same name.

EDIT: another option that exists in 2014, that did not in 2009, is SpriteKit. Depending on what you might be doing that needs a sprite sheet, that might be useful.

like image 144
Sixten Otto Avatar answered Sep 21 '22 15:09

Sixten Otto