• 发光动画


    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [whiteView setBackgroundColor:[UIColor whiteColor]];
    [whiteView setUserInteractionEnabled:NO];
    [self.view addSubview:whiteView];

    CALayer *maskLayer = [CALayer layer];

    // Mask image ends with 0.15 opacity on both sides. Set the background color of the layer
    // to the same value so the layer can extend the mask image.
    maskLayer.backgroundColor = [[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.0f] CGColor];
    maskLayer.contents = (id)[[UIImage imageNamed:@"ShineMask.png"] CGImage];

    // Center the mask image on twice the width of the text layer, so it starts to the left
    // of the text layer and moves to its right when we translate it by width.
    maskLayer.contentsGravity = kCAGravityCenter;
    maskLayer.frame = CGRectMake(-whiteView.frame.size.width,
                                 0.0f,
                                 whiteView.frame.size.width * 2,
                                 whiteView.frame.size.height);

    // Animate the mask layer's horizontal position
    CABasicAnimation *maskAnim = [CABasicAnimation animationWithKeyPath:@"position.x"];
    maskAnim.byValue = [NSNumber numberWithFloat:self.view.frame.size.width * 9];
    maskAnim.repeatCount = HUGE_VALF;
    maskAnim.duration = 3.0f;
    [maskLayer addAnimation:maskAnim forKey:@"shineAnim"];

    whiteView.layer.mask = maskLayer;

  • 相关阅读:
    内网渗透中命令行下文件分卷压缩
    Windows&Linux重置nessus的密码
    mac 安装zmap
    Java的几种时间
    Hadoop-MR实现日志清洗(四)
    Hadoop-MR实现日志清洗(三)
    Hadoop-MR实现日志清洗(二)
    Hadoop-MR实现日志清洗(一)
    关于Hive正则技术处理比较规范的日志数据
    创建一个普通的Java项目,编写MapReduce程序
  • 原文地址:https://www.cnblogs.com/chenfulai/p/2590009.html
Copyright © 2020-2023  润新知