zoukankan      html  css  js  c++  java
  • 核心动画的使用

    1、活动指示器

    • 1.1 创建活动指示器

      @property (nonatomic, strong) UIView *activityIndicatorView;
      
      self.activityIndicatorView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
      self.activityIndicatorView.backgroundColor = [UIColor redColor];
      [self.view addSubview:self.activityIndicatorView];
      
      // 创建复制图层
      CAReplicatorLayer *repLayer = [CAReplicatorLayer layer];                    // 可以把图层里面所有子层复制
      repLayer.frame = self.activityIndicatorView.bounds;
      [self.activityIndicatorView.layer addSublayer:repLayer];
      
      // 创建指示器图层
      CALayer *layer = [CALayer layer];
      layer.transform = CATransform3DMakeScale(0, 0, 0);
      layer.position = CGPointMake(self.activityIndicatorView.bounds.size.width / 2, 20);
      layer.bounds = CGRectMake(0, 0, 10, 10);
      layer.backgroundColor = [UIColor greenColor].CGColor;
      [repLayer addSublayer:layer];
      
      // 设置缩放动画
      CGFloat duration = 1.0;
      CABasicAnimation *anim = [CABasicAnimation animation];
      anim.keyPath = @"transform.scale";
      anim.fromValue = @1;
      anim.toValue = @0;
      anim.duration = duration;
      anim.repeatCount = MAXFLOAT;
      [layer addAnimation:anim forKey:nil];
      
      // 设置复制层中子层
      CGFloat count = 20;
      CGFloat angle = M_PI * 2 / count;
      repLayer.instanceCount = count;                                             // 设置复制层里面有多少个子层,包括原始层
      repLayer.instanceTransform = CATransform3DMakeRotation(angle, 0, 0, 1);     // 设置复制子层偏移量,不包括原始层,相对于原始层 x 偏移
      repLayer.instanceDelay = duration / count;                                  // 设置复制层动画延迟时间
      
    • 1.2 效果

  • 相关阅读:
    java命令模式;
    java 基于Socket实现QQ聊天小系统
    java 考试系统,类似驾考宝典
    jmeter之认识元器件及功能 大杂烩
    java GUI
    Codeforces Round #382 (Div. 1) A. Tennis Championship
    Hrbust-1316-移动 II(广度优先搜索 路径记录)
    Hrbust-1942-this is bad problom(搜索)
    Hrbust-1287-数字去重和排序II(set集合容器应用)
    Hrbust-1012-Catch That Cow(广搜BFS入门)
  • 原文地址:https://www.cnblogs.com/CH520/p/9480746.html
Copyright © 2011-2022 走看看