views:

134

answers:

1

Is there a way to tile an image in objective-j on a CPView? something along the lines of:

  • [CPImage alloc] initWithPatternImage:@"Resources/grid.png" size:CGSizeMake(5.0, 5.0)]

Thanks guys ;)

A: 

Try this:

var image = [[CPImage alloc]
                initWithContentsOfFile:"Resources/myimage.gif"
                                  size:CGSizeMake(20, 20)]; 
var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(0,0,500,500)];    
[imageView setBackgroundColor:[CPColor colorWithPatternImage:image]];
Paul
You can set the background on any view, and you _shouldn't_ set it on an image view usually. Just remove the imageView line, and call the same thing on the regular view.patternImage's are automatically tiled when they are view backgrounds.
Ross Boucher
Cheers Ross :) - I'm still learning this myself.
Paul