心电图动画效果

心电图动画效果

 

效果

 

源码

https://github.com/YouXianMing/Animations

//
//  BezierPathViewController.m
//  Animations
//
//  Created by YouXianMing on 16/1/11.
//  Copyright  2016年 YouXianMing. All rights reserved.
//

#import "BezierPathViewController.h"
#import "UIView+SetRect.h"
#import "CALayer+SetRect.h"
#import "UIFont+Fonts.h"
#import "UIView+AnimationProperty.h"
#import "GCD.h"

@interface BezierPathViewController ()

@property (nonatomic, strong) GCDTimer      *timer;
@property (nonatomic, strong) CAShapeLayer  *shapeLayer;

@end

@implementation BezierPathViewController

- (void)setup {

    [super setup];

    self.backgroundView.backgroundColor = [UIColor blackColor];

    // Used as background.
    {
        CAShapeLayer *shapeLayer = [CAShapeLayer layer];
        shapeLayer.frame         = CGRectMake(0, 0, 600, 300);
        shapeLayer.path          = [self path].CGPath;

        shapeLayer.fillColor   = [UIColor clearColor].CGColor;
        shapeLayer.strokeColor = [UIColor redColor].CGColor;
        shapeLayer.lineWidth   = 0.5f;
        shapeLayer.opacity     = 0.5f;
        shapeLayer.position    = self.contentView.middlePoint;
        shapeLayer.shadowColor = [UIColor redColor].CGColor;
        [shapeLayer setTransform:CATransform3DMakeScale(0.65, 0.65, 1.f)];

        [self.contentView.layer addSublayer:shapeLayer];
    }

    // Animation.
    {
        self.shapeLayer           = [CAShapeLayer layer];
        self.shapeLayer.frame     = CGRectMake(0, 0, 600, 300);
        self.shapeLayer.path      = [self path].CGPath;
        self.shapeLayer.strokeEnd = 0.f;

        self.shapeLayer.fillColor     = [UIColor clearColor].CGColor;
        self.shapeLayer.strokeColor   = [UIColor redColor].CGColor;
        self.shapeLayer.lineWidth     = 2.f;
        self.shapeLayer.position      = self.contentView.middlePoint;
        self.shapeLayer.shadowColor   = [UIColor redColor].CGColor;
        self.shapeLayer.shadowOpacity = 1.f;
        self.shapeLayer.shadowRadius  = 4.f;
        [self.shapeLayer setTransform:CATransform3DMakeScale(0.65, 0.65, 1.f)];
        [self.contentView.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 *)path {

    UIBezierPath* bezierPath = [UIBezierPath bezierPath];
    [bezierPath moveToPoint: CGPointMake(0, 150)];
    [bezierPath addLineToPoint: CGPointMake(68, 150)];
    [bezierPath addLineToPoint: CGPointMake(83, 107)];
    [bezierPath addLineToPoint: CGPointMake(96, 206)];
    [bezierPath addLineToPoint: CGPointMake(102, 150)];
    [bezierPath addLineToPoint: CGPointMake(116, 150)];
    [bezierPath addLineToPoint: CGPointMake(127, 82)];
    [bezierPath addLineToPoint: CGPointMake(143, 213)];
    [bezierPath addLineToPoint: CGPointMake(160, 150)];
    [bezierPath addLineToPoint: CGPointMake(179, 150)];
    [bezierPath addLineToPoint: CGPointMake(183, 135)];
    [bezierPath addLineToPoint: CGPointMake(192, 169)];
    [bezierPath addLineToPoint: CGPointMake(199, 150)];
    [bezierPath addLineToPoint: CGPointMake(210, 177)];
    [bezierPath addLineToPoint: CGPointMake(227, 70)];
    [bezierPath addLineToPoint: CGPointMake(230, 210)];
    [bezierPath addLineToPoint: CGPointMake(249, 135)];
    [bezierPath addLineToPoint: CGPointMake(257, 150)];
    [bezierPath addLineToPoint: CGPointMake(360, 150)];
    [bezierPath addLineToPoint: CGPointMake(372, 124)];
    [bezierPath addLineToPoint: CGPointMake(395, 197)];
    [bezierPath addLineToPoint: CGPointMake(408, 82)];
    [bezierPath addLineToPoint: CGPointMake(416, 150)];
    [bezierPath addLineToPoint: CGPointMake(424, 135)];
    [bezierPath addLineToPoint: CGPointMake(448, 224)];
    [bezierPath addLineToPoint: CGPointMake(456, 107)];
    [bezierPath addLineToPoint: CGPointMake(463, 150)];
    [bezierPath addLineToPoint: CGPointMake(600, 150)];
    bezierPath.lineCapStyle = kCGLineCapSquare;

    bezierPath.lineJoinStyle = kCGLineJoinBevel;

    [UIColor.blackColor setStroke];
    bezierPath.lineWidth = 1;
    [bezierPath stroke];

    return bezierPath;
}

- (void)buildTitleView {

    [super buildTitleView];

    [self.titleView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

        [obj removeFromSuperview];
    }];

    // Title label.
    UILabel *headlinelabel      = [UILabel new];
    headlinelabel.font          = [UIFont AvenirWithFontSize:20.f];
    headlinelabel.textAlignment = NSTextAlignmentCenter;
    headlinelabel.textColor     = [[UIColor whiteColor] colorWithAlphaComponent:0.75f];
    headlinelabel.text          = self.title;
    [headlinelabel sizeToFit];

    headlinelabel.center = self.titleView.middlePoint;

    // Line.
    UIView *line         = [[UIView alloc] initWithFrame:CGRectMake(0, 63.5, self.view.width, 0.5f)];
    line.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.25f];
    [self.titleView addSubview:line];
    [self.titleView addSubview:headlinelabel];

    // Back button.
    UIImage  *image      = [UIImage imageNamed:@"backIconVer2"];
    UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 64)];
    backButton.center    = CGPointMake(20, self.titleView.middleY);
    [backButton setImage:image forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(popSelf) forControlEvents:UIControlEventTouchUpInside];
    [backButton.imageView setContentMode:UIViewContentModeCenter];
    [self.titleView addSubview:backButton];
}

- (void)popSelf {

    [self popViewControllerAnimated:YES];
}

@end

细节

 

时间: 2024-09-04 07:40:15

心电图动画效果的相关文章

从顶部出现窗体动画效果

问题描述 从顶部出现窗体动画效果 这个都是从底部,从顶部怎么做呀?请您这边就是说我们这边的文件信息提示,我们这边的文件,实现不了我的这个功能

在Fireworks中制作淡入淡出动画效果

淡出|淡入 淡入淡出动画效果 用fireworks做的淡入淡出效果,有人说看PNG格式看不出真正的步骤,所以在此补上这样一篇教程. 对象的淡入淡出效果是firewoks可以创建的普通效果之一,对两个链接对象进行插帧的时候,其中一个对象的不透明度设置为0%,一个对象的不透明度设置为100%,就可以获得淡入淡出效果. 制作步骤: 一.首先新建一个文件,画一个圆,在FILL面板中设置edge:feather:10,设feather的目的是在运动过程中边缘不至于太生硬,影响效果.点中圆,按F8键,选择t

UILabel混合显示动画效果

UILabel混合显示动画效果   效果   源码 https://github.com/YouXianMing/Animations // // MixedColorProgressViewController.m // Animations // // Created by YouXianMing on 16/1/5. // Copyright 2016年 YouXianMing. All rights reserved. // #import "MixedColorProgressView

FLASH中实现眨眼睛的动画效果

许多FLASH动画短片和MV中经常有精美生动的动画人物出现,配合眨眼动作.口形变化以及头发的飘动,再加上人物的配音,一个活脱脱的动画人物形象就出现在FLASH动画中了.很多人都想知道这样的人物是如何做得栩栩如生的,尤其是其中的简单动画效果,如眨眼的动作,如何制作人物的眨眼动画呢?其实技巧很简单,甚至都不需要专门教程来指导,但是对于初学者,笔者认为却是应该用一个实例教程来给予指导的.最近发现帝国的在线教程中也有很多这样的提问--"在FLASH中如何制作效果逼真的人物眨眼效果?",其他的F

PS制作创意心形动态时钟GIF动画效果教程

首声明下: 1.此教程为原创.非喜勿喷. 2.菜鸟教程.顾名思义.是教PS新人的.高手勿笑.勿打酱油.有什么更好的建议可以提出来. 3.图可能做得不好看.但是这个是可以按自己喜欢来做的.我教的只是技巧. 4.我很用心做的.也请你们认真的看.不懂可以问. 效果图: 忘了说.可以添加一些投影效果. 相关教程: PhotoShop简单制作扭动的文字GIF动态效果教程 PhotoShop制作滚动图片GIF动画效果图文教程 PhotoShop简单制作扭动的文字GIF动态效果教程   分类: PS入门教程

PS制作光影来回滚动扫描文字GIF动画效果教程

教大家用PhotoShop制作一种光影来加滚动扫描文字GIF动态效果,做这种效果的动画还是属于比较简单的,喜欢GIF动画的同学可以学习一下! 效果图: 1.新建图层,打上你喜欢的字. 2.创建新图层 3.用"画笔"工具在此画一笔(前景颜色便是画笔的颜色) 4.点击"窗口"---"动画"导出动画栏     相关GIF教程: PhotoShop制作用笔写字(手写字)GIF动画效果教程 PS简单制作旋转起来的太极阴阳字GIF动态图效果教程 PhotoS

Flash AtionScrip 3.0制作逼真的雪花飘飘的gif动画效果

  本例为用Flash AtionScrip 3.0制作逼真的雪花飘飘的gif动画效果教程,常常从网上的动画中看到大雪纷飞的场面,看到雪花从天空中拖曳而下,真有一种身临其境的感觉呢?但主要是用AtionScrip 2.0制作,现在我们用AtionScrip 3.0来制作雪景效果. 效果演示: 一.制作雪花元件 1.打开 Flash9.0,新建Flash文档选择AtionScrip 3.0.背景色为深蓝,舞台大小为 550×400.然后按下 Ctrl+F8,新建一个影片剪辑元件"雪花",

推荐9款使用CSS3实现的超酷动画效果

大家都知道,在网页制作时使用CSS技术,可以有效地对页面的布局.字体.颜色.背景和其它效果实现更加精确的控制.只要对相应的代码做一些简单的 修改,就可以改变同一页面的不同部分,或者页数不同的网页的外观和格式.CSS3是CSS技术的升级版本,CSS3语言开发是朝着模块化发展的.本周极客 社区推荐9款使用CSS3实现的超酷前端动画效果.希望对大家有所帮助! 让我们晃动起来 - CSS小脚本工具:CSS Shake UI或者网站设计中,或许在某些情况下你希望你的用户能够关注某一个区域或者某一个界面元素

jQuery教程:制作滑动动画效果的层

使用jQuery制作滑动动画效果的层 基本原理 这些具有动态效果的滑动盒都基于同样的基本原理.在你经过想要"窥见"对象中的其他两个项目,这个带有".boxgrid"的DIV标签充当着一个窗口.还不明白? 让这个图片来给你线索吧: 理解了这个基本原理之后,我们就可以利用滑动元素的动画效果来揭开或遮盖住要展示的区域,以此来创造滑动效果. 第一步 – CSS 基础工作 在上面给出基本结构的启示图中,我们需要使用一点CSS来让它显示出预期的效果.下面这个CSS定义了查看窗口