Is there a way to repeat an UIImage inside a rectangle using CoreGraphics? It's kind of like http://www.raywenderlich.com/33496/core-graphics-tutorial-patterns, but I'm gonna use an image loaded from file.
Asked
Active
Viewed 507 times
-1
-
See http://stackoverflow.com/q/19490970/763355 – MoDJ Jun 11 '16 at 22:12
1 Answers
3
Use the image as a pattern color:
UIColor *color = [[UIColor alloc] initWithPatternImage:myImage];
someView.backgroundColor = color;
Not exactly Core Graphics, though. If you really need it there's CGColorCreateWithPattern
. It's a bit more code to set up.

Nikolai Ruhe
- 81,520
- 17
- 180
- 200
-
That's cool. I'm trying to make a SKTexture and/or SKSpriteNode out of it in the end and seeing as there is `[SKSpriteNode spriteNodeWithColor:colorTest size:CGSizeMake(300, 300)];` I gave it a go, alas it doesn't seem to like a "image color". – Jonny Sep 18 '13 at 10:35
-
1@Jonny See http://stackoverflow.com/questions/19490970/sprite-kit-and-colorwithpatternimage/19833309#19833309 – David Lawson Nov 07 '13 at 10:19