IOS 雷达效果(Layer的动画)笔记
2014-06-18 14:45
423 查看
// // LPViewController.m // LayerDemo // // Created by linpeng on 14-6-17. // Copyright (c) 2014年 linpeng. All rights reserved. // #import "LPViewController.h" @interface LPViewController () { CALayer *sublayer2,*sublayer3; } @end @implementation LPViewController - (void)viewDidLoad { [super viewDidLoad]; UIView *v = [[UIView alloc] initWithFrame:self.view.frame]; [v setBackgroundColor:[UIColor grayColor]]; v.layer.backgroundColor = [UIColor whiteColor].CGColor; [self.view addSubview:v]; sublayer2 = [CALayer layer]; sublayer2.borderWidth = 0.5f; sublayer2.borderColor = [UIColor redColor].CGColor; sublayer2.frame = CGRectMake(10, 10, 60, 60); sublayer2.cornerRadius = 60/2; sublayer2.position = v.center; sublayer2.backgroundColor = [UIColor greenColor].CGColor; [v.layer addSublayer:sublayer2]; int count = 4; float duration = 4.0; for (int i = 0; i<count; i++) { CALayer *lay = [CALayer layer]; lay.borderWidth = 0.1f; lay.borderColor = [UIColor redColor].CGColor; lay.frame = CGRectMake(10, 10, 60, 60); lay.cornerRadius = lay.frame.size.width/2; lay.position = v.center; [v.layer addSublayer:lay]; CABasicAnimation *scaleAnimation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; scaleAnimation1.fromValue = [NSNumber numberWithFloat:1.0]; scaleAnimation1.toValue = [NSNumber numberWithFloat:10.0]; scaleAnimation1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; opacityAnimation.fromValue = [NSNumber numberWithFloat:1.0]; opacityAnimation.toValue = [NSNumber numberWithFloat:0]; CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; animationGroup.fillMode = kCAFillModeBackwards; animationGroup.duration = duration; animationGroup.autoreverses = NO; //是否重播,原动画的倒播 animationGroup.repeatCount = HUGE_VAL;//HUGE_VALF; //HUGE_VALF,源自math.h [animationGroup setAnimations:[NSArray arrayWithObjects:opacityAnimation, scaleAnimation1, nil]]; animationGroup.beginTime = CACurrentMediaTime()+i*duration/count; [lay addAnimation:animationGroup forKey:@"group"]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- ios 动画效果CATransition笔记
- 【iOS学习笔记 15-11-06】简单自定义navigationcontroller push和pop动画效果
- iOS CAReplicatorLayer 实现脉冲动画效果
- ios开发oc高仿京东金融白条额度余额的 ios开发水波纹 ios开发水正弦曲线波纹 ios开发雷达扫描的动画效果
- 【iOS开发-24】导航控制器下不同视图控制器之间切换:利用CATrasition和view的layer层来实现自定义的动画效果
- iOS核心动画笔记3-视觉效果
- iOS CAReplicatorLayer实现脉冲动画效果
- ios开发oc高仿京东金融白条额度余额的 ios开发水波纹 ios开发水正弦曲线波纹 ios开发雷达扫描的动画效果
- iOS开发导航控制器下不同视图控制器之间切换:利用CATrasition和view的layer层来实现自定义的动画效果
- iOS核心动画实现仿支付宝咻咻、雷达效果
- iOS开发笔记 — Text、UI交互细节、两个动画效果等
- iOS CAEmitterLayer 实现粒子发射动画效果
- iOS学习笔记---iOS用view实现推出菜单栏的动画效果
- iOS开发雷达动画效果实现
- iOS开发笔记--视图切换的动画效果
- iOS UIView动画效果 学习笔记
- iOS CAEmitterLayer实现粒子发射动画效果
- iOS 雷达动画效果实现
- iOS开发之iOS中的动画实现,通过CAShapeLayer、CAShapeLayer,CAReplicatorLayer实现炫酷的动画、雷达效果,波纹效果,咻一咻效果。iOS核心动画实现。
- iOS开发笔记 — Text、UI交互细节、两个动画效果等