为UILabe添加颜色渐变效果的Category
#import "UILabel+Gradient.h"
NSValue *v1 = [NSValue valueWithVector:GradientVectorMake(0,1,0,0)];
NSValue *v2 = [NSValue valueWithVector:GradientVectorMake(1,0,0,0)];
NSValue *v3 = [NSValue valueWithVector:GradientVectorMake(0,1,1,0)];
UIColor *c1 = RGBCOLOR(84, 84, 84);
UIColor *c2 = RGBCOLOR(67, 145, 204);
UIColor *c3 = RGBCOLOR(101, 204, 121);
[_titleLabel addGradientColors:@[c1,c2,c3]
intervals:@[@(1.8),@(1.2),@(1.4)]
vectors:@[v1,v2,v3]
hideen:YES
finishBlock:^{
NSLog(@"渐变完成了");
[self imageAnimation];
}];
- 从左向右
GradientVectorMake(0,0,1,0)
- 从右向左
GradientVectorMake(1,0,0,0)
- 从上向下
GradientVectorMake(0,0,0,1)
- 从下向上
GradientVectorMake(0,1,0,0)
- 从左上向右下
GradientVectorMake(0,0,1,1)
- 从右下向左上
GradientVectorMake(1,1,0,0)
- 从左下向右上
GradientVectorMake(0,1,1,0)
- 从右上向左下
GradientVectorMake(1,0,0,1)