心电图动画
来源:互联网 发布:海魂衫 淘宝 编辑:程序博客网 时间:2024/04/24 06:52
心跳动画
在博客上看到youxianming[http://www.cnblogs.com/YouXianMing/p/5122580.html]上传的心电图动画,不禁模仿了一番。仅供学习,向youxianming致敬。
//// ViewController.m// AnimationTest//// Created by Zhang Runchao on 16/3/11.// Copyright © 2016年 test. All rights reserved.//#import "ViewController.h"#import "UIView+SetRect.h"#import "UIView+AnimationProperty.h"#import "WxHxD.h"#import "GCD.h"@interface ViewController ()@property(nonatomic,strong) UIView *animationView;@property(nonatomic,strong) CAShapeLayer *shapeLayer;@property(nonatomic,strong) GCDTimer *timer;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // 画布 [self setupAnimationView]; //心跳 [self setupHeartBeat];}-(void)setupAnimationView{ self.animationView = [[UIView alloc] initWithFrame:CGRectMake(0, 80,Width , 200)]; [self.animationView setBackgroundColor:[UIColor blackColor]]; [self.view addSubview:self.animationView];}-(void)setupHeartBeat{ //background layer { CAShapeLayer *layer = [CAShapeLayer layer]; layer.frame = self.animationView.frame; UIBezierPath *path = [self heartBeatBezierPath]; layer.path = path.CGPath; layer.lineWidth = .5f; layer.fillColor = [[UIColor clearColor] CGColor]; layer.strokeColor = [[UIColor redColor] CGColor]; layer.opacity = .5f; layer.position = self.animationView.middlePoint; layer.shadowColor = [[UIColor redColor] CGColor]; [layer setTransform:CATransform3DMakeScale(.65f, .65f, 1)]; [self.animationView.layer addSublayer:layer]; } { self.shapeLayer = [CAShapeLayer layer]; self.shapeLayer.frame = self.animationView.frame; self.shapeLayer.path = [self heartBeatBezierPath].CGPath; self.shapeLayer.fillColor = [[UIColor clearColor] CGColor]; self.shapeLayer.strokeColor = [[UIColor redColor] CGColor]; self.shapeLayer.strokeEnd = 0; self.shapeLayer.lineWidth = 2; self.shapeLayer.position = self.animationView.middlePoint; self.shapeLayer.shadowColor = [[UIColor redColor] CGColor]; self.shapeLayer.shadowOpacity = 1; self.shapeLayer.shadowRadius = 4.f; [self.shapeLayer setTransform:CATransform3DMakeScale(.65f, .65f, 1.f)]; [self.animationView.layer addSublayer:self.shapeLayer]; CGFloat MAX = 0.98f; CGFloat GAP = 0.02; self.timer = [[GCDTimer alloc] initInQueue:[GCDQueue mainQueue]]; [self.timer event:^{ CABasicAnimation *aniStart = [CABasicAnimation animationWithKeyPath:@"strokeStart"]; aniStart.fromValue = [NSNumber numberWithFloat:0.f]; aniStart.toValue = [NSNumber numberWithFloat:MAX]; aniStart.duration = 4.9f; CABasicAnimation *aniEnd = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; aniEnd.fromValue = [NSNumber numberWithFloat:0.f+GAP]; aniEnd.toValue = [NSNumber numberWithFloat:MAX+GAP]; aniEnd.duration = 4.9f; CAAnimationGroup *group = [CAAnimationGroup animation]; group.duration = 4.9f; group.animations = @[aniEnd,aniStart]; self.shapeLayer.strokeStart = MAX; self.shapeLayer.strokeEnd = MAX + GAP; [self.shapeLayer addAnimation:group forKey:nil]; } timeIntervalWithSecs:5.f delaySecs:1.f]; [self.timer start]; }}//生成贝塞尔-(UIBezierPath*)heartBeatBezierPath{ UIBezierPath *path = [UIBezierPath bezierPath]; //画路径 [path moveToPoint:CGPointMake(0, 100)]; [path addLineToPoint:CGPointMake(20, 100)]; [path addLineToPoint:CGPointMake(35, 150)]; [path addLineToPoint:CGPointMake(50, 50)]; [path addLineToPoint:CGPointMake(65, 185)]; [path addLineToPoint:CGPointMake(80, 100)]; [path addLineToPoint:CGPointMake(95, 100)]; [path addLineToPoint:CGPointMake(110, 20)]; [path addLineToPoint:CGPointMake(125, 170)]; [path addLineToPoint:CGPointMake(140, 40)]; [path addLineToPoint:CGPointMake(155, 100)]; [path addLineToPoint:CGPointMake(175, 100)]; [path addLineToPoint:CGPointMake(200, 150)]; [path addLineToPoint:CGPointMake(215, 10)]; //线连接处样式 path.lineCapStyle = kCGLineCapSquare; //线终点处样式 path.lineJoinStyle = kCGLineJoinBevel; [[UIColor blackColor] setStroke]; path.lineWidth = 1; //根据坐标点连线 [path stroke]; return path;}@end
0 0
- 心电图动画
- 心电图动画
- photoshop做心电图gif动画
- 心电图诊断 样本心电图
- 心电图项目
- java心电图
- ECGWaveView心电图
- 奇妙的心电图数列
- 心电图学 书籍推荐
- 心电图速成手册
- 心电图诊断学习笔记
- iOS 心电图绘制Demo
- Android 实现心电图
- canvas 绘制心电图
- 简单的心电图
- JFreeChart 画心电图
- 心电图的压缩传感
- java心电图参考
- uva11795 Mega Man's Mission
- HTTP详解
- 让Maven项目使用Nexus作为远程仓库的settings.xml配置
- Echarts制作图表教程一------柱状图
- 关于display:tag的使用
- 心电图动画
- JavaScript鼠标移动获取坐标
- leetcode:Contains Duplicate 【Java】
- Html+Css JavaEE highChart使用指南:
- 婚姻危机中的真正原因是这个
- xcode 7.2 中通过拖拉在Main.storyboard 中定制tabbar
- 分类添加属性之关联引用
- java类
- Linux服务器安全配置