首页 > 其他 > 详细

UIView 添加闪烁的渐变光

时间:2016-12-13 16:16:02      阅读:282      评论:0      收藏:0      [点我收藏+]
CGRect gradientRect=CGRectMake(- imageView3.bounds.size.width*1.5, 0, 4 * imageView3.bounds.size.width, imageView3.bounds.size.height);
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.frame =gradientRect;
    gradientLayer.colors = @[(id)hexColor(bb975e).CGColor,(id)[UIColor whiteColor].CGColor,(id)hexColor(bb975e).CGColor];
    gradientLayer.locations = @[@(0.25),@(0.5),@(0.75)];
    gradientLayer.startPoint = CGPointMake(0, 0.5);
    gradientLayer.endPoint = CGPointMake(1, 0.5);
    gradientLayer.position = CGPointMake(imageView3.bounds.size.width*0.5, imageView3.bounds.size.height/2.0);
    [imageView3.layer addSublayer:gradientLayer];
    
    CALayer *maskLayer = [CALayer layer];
    maskLayer.frame =CGRectOffset(imageView3.bounds, imageView3.bounds.size.width*1.5, 0);
    maskLayer.contents = (__bridge id)([UIImage imageNamed:@"launchImage3"].CGImage);
    gradientLayer.mask = maskLayer;
    
    CABasicAnimation* fadeAnim = [CABasicAnimation animationWithKeyPath:@"locations"];
    fadeAnim.fromValue = @[@(0.0),@(0.0),@(0.25)];
    fadeAnim.toValue = @[@(0.75),@(1.0),@(1.0)];
    fadeAnim.duration=2;
    fadeAnim.repeatCount = CGFLOAT_MAX;
    [gradientLayer addAnimation:fadeAnim forKey:nil];

 

UIView 添加闪烁的渐变光

原文:http://www.cnblogs.com/dhui69/p/6170059.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!