//
// ViewController.m
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// 创建一个复制图层
CAReplicatorLayer *relayer = [CAReplicatorLayer layer];
relayer.frame = _bgView.bounds;
[_bgView.layer addSublayer:relayer];
// 创建layer
CALayer *layer = [CALayer layer];
layer.anchorPoint = CGPointMake(0.5, 1);
layer.position = CGPointMake(15, _bgView.bounds.size.height);
layer.bounds = CGRectMake(0, 0, 20, 150);
layer.backgroundColor = [UIColor redColor].CGColor;
[relayer addSublayer:layer];
// 添加动画
CABasicAnimation *animation = [CABasicAnimation animation];
animation.keyPath = @"transform.scale.y";
animation.toValue = @0.1;
animation.duration = 0.5;
animation.repeatCount = MAXFLOAT;
animation.autoreverses = YES; // 动画反转
[layer addAnimation:animation forKey:nil];
// 复制子层
// instanceCount:表示relayer里有多少子层
relayer.instanceCount = 6;
// 设置子层偏移量,相对于原始层
relayer.instanceTransform = CATransform3DMakeTranslation(40, 0, 0);
// 设置动画延迟时间
relayer.instanceDelay = 0.1;
}
@end
音量柱状振动条动画
最新推荐文章于 2020-12-31 02:33:52 发布