Question

I currently have an image which has every suit and value of a deck of playing cards in it. There is an UIImageView to show this picture, with width and height set to show just one card at a time and view mode set to "top left" so it doesn't stretch.

alt text

Now I'm just showing what happens to be the top left card, the ace of clubs. I tried finding a way to offset the view to show a different portion of the UIImage, but couldn't find a suitable property (tried fiddling with "frame" and "bounds").

Is there a way to get such an offset working, or am I going about this the wrong way? I'd like to keep all the cards in one image in "sprite sheet" style so that they would be easy to modify later instead of having a bunch of separate pics.

Was it helpful?

Solution

Set the bounds to what you'd like to show, enable 'clipToBounds' and make sure the content stretch mode is set properly. That should work.

EDIT: I do recommend making different images though, because of memory issues (even though not the whole image is shown, you still fully have it in memory).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top