Can text in UILabel have colorWithPatternImage: assigned to it?

If so, is it possible to animate the image?

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

+3
source share
1 answer

Yes, the label can have a template 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

A template can be animated by switching between several template colors. I flipped through the image with the picture and the usual color at> 30 frames per second, and the iPhone continued normally.

While the image tile is small, I see no reason not to do this, but I did not profile it.

+6
source

Source: https://habr.com/ru/post/1710962/


All Articles