iOS 关机文字动态图

    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;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容