美文网首页
iOS 类似于关机时动画

iOS 类似于关机时动画

作者: 丘名山 | 来源:发表于2018-08-07 11:39 被阅读0次

        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;

    相关文章

      网友评论

          本文标题:iOS 类似于关机时动画

          本文链接:https://www.haomeiwen.com/subject/vdmovftx.html