UILabel中的文本可以有colorWithPatternImage:分配给它吗? [英] Can text in UILabel have a colorWithPatternImage: assigned to it?
本文介绍了UILabel中的文本可以有colorWithPatternImage:分配给它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果是这样,图像可以动画吗?
If so, can the image be animated?
有充分的理由不这样做吗?内存使用情况等?
Is there a good reason not to do this? Memory usage, etc?
推荐答案
是的,标签可以有图案颜色。
Yes, a label can have a pattern color.
替代文字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
可以通过在多种图案颜色之间切换来设置图案的动画效果。我已经在> 30fps的图案图像和普通颜色之间翻转,并且iPhone设备保持良好状态。
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.
这篇关于UILabel中的文本可以有colorWithPatternImage:分配给它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文