I want to be able to an UI object like a UIImageView and tile an image inside of it.
I have been able to use CGContextDrawTiledImage to update the background in the
Sorry for not knowing how to add comment to other's answers, so I created a new answer here:
I just want to point out the answer provided by Kailoa Kadano has a bug, the image_rect.origin is not initialized properly.
About 3 weeks ago, I copied his code in my project, and it seems working. However, yesterday, I tried to run the code in ios simulator(iphone 4.3), it just hang in CGContextDrawTiledImage. After adding the following line as showed in keremk's answer:
image_rect.origin = CGPointMake(0.0, 0.0);
it works again!
It's rather tricky, actually at first I tested under iphone 4.3 simulator, then recently I tested under iphone 4.0 simulator, then yesterday when I switched back to 4.3 simulator or 4.2 simulator, the problem occurs. That is the image_rect.origin is undefined, sometimes it's zero data, maybe sometimes it has some random data.