UILabel*textLabel = [[UILabelalloc]initWithFrame:CGRectMake(0, SubmissionbuttonFloat+10,kScreenWidth,30)];
textLabel.text = @"这只是一个测试,试测个一是只这";
textLabel.textAlignment = NSTextAlignmentCenter;
textLabel.textColor= [UIColorpurpleColor];
[self.viewaddSubview:textLabel];
//
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame= textLabel.bounds;
gradientLayer.colors = @[(__bridge id)[[UIColor greenColor] colorWithAlphaComponent:0.3].CGColor,(__bridge id)[UIColor yellowColor].CGColor,(__bridge id)[[UIColor blueColor] colorWithAlphaComponent:0.3].CGColor];
gradientLayer.locations=@[@(0.0),@(0.0),@(0.1)];
gradientLayer.startPoint=CGPointMake(0,0);//设置渐变方向起点
gradientLayer.endPoint=CGPointMake(1,0); //设置渐变方向终点
//开始动画
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"locations"];
animation.duration=3.0f;
animation.toValue = @[@(0.3),@(0.6),@(1.0)];
animation.removedOnCompletion = NO;
animation.repeatCount=HUGE_VALF;
animation.fillMode = kCAFillModeForwards;
[gradientLayeraddAnimation:animationforKey:@"xindong"];
textLabel.layer.mask= gradientLayer;
网友评论