Question

If so, can the image be animated?

Is there a good reason not to do this? Memory usage, etc?

Was it helpful?

Solution

Yes, a label can have a pattern color.

alt text http://img178.imageshack.us/img178/1995/textwithpatterncolor.png

// make a UIColor with an image as the pattern
UIImage *tileImage = [UIImage imageNamed:@"hot_grad_64px.png"];
UIColor *patternColorTile = [UIColor colorWithPatternImage:tileImage];

// assign it to the .textColor property of a UILabel
self.testLabel.textColor = patternColorTile;

// the pattern will only align if both the .frame property of the 
// label AND the font size is the same as the image tile height

The pattern can be animated by switching between multiple pattern colors. I have flipped between a pattern image and a plain color at > 30fps and the iPhone device kept up fine.

As long as the image tile is small, I don't see any reason not to do this, but I haven't extensively profiled it.

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