Uilabel의 텍스트가 색상을 가질 수 있습니까?
-
06-07-2019 - |
문제
그렇다면 이미지를 애니메이션 할 수 있습니까?
이것을하지 않는 좋은 이유가 있습니까? 메모리 사용 등?
해결책
예, 레이블은 패턴 색상을 가질 수 있습니다.
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
여러 패턴 색상을 전환하여 패턴을 애니메이션 할 수 있습니다. > 30fps에서 패턴 이미지와 일반 색상 사이를 뒤집었고 iPhone 장치는 잘 유지되었습니다.
이미지 타일이 작는 한, 나는 이것을하지 않을 이유가 없지만 광범위하게 프로파일 링하지 않았습니다.
제휴하지 않습니다 StackOverflow