博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POP的Stroke动画
阅读量:5063 次
发布时间:2019-06-12

本文共 2677 字,大约阅读时间需要 8 分钟。

POP的Stroke动画

 

效果

源码

////  PopStrokeController.m//  Animations////  Created by YouXianMing on 15/11/17.//  Copyright © 2015年 YouXianMing. All rights reserved.//#import "PopStrokeController.h"#import "GCD.h"#import "POP.h"#import "StrokeCircleLayerConfigure.h"@interface PopStrokeController ()@property (nonatomic, strong) CAShapeLayer  *circleShape;@property (nonatomic, strong) GCDTimer      *timer;@end@implementation PopStrokeController- (void)viewDidLoad {        [super viewDidLoad];}- (void)setup {        [super setup];        self.circleShape = [CAShapeLayer layer];    self.circleShape.strokeEnd = 0.f;    self.circleShape.lineCap   = kCALineCapRound;    StrokeCircleLayerConfigure *config = [StrokeCircleLayerConfigure new];    config.lineWidth    = 4.f;    config.startAngle   = 0;    config.endAngle     = M_PI * 2;    config.radius       = 55.f;    config.circleCenter = self.view.center;    config.strokeColor  = [UIColor cyanColor];    [config configCAShapeLayer:self.circleShape];    [self.view.layer addSublayer:self.circleShape];        _timer = [[GCDTimer alloc] initInQueue:[GCDQueue mainQueue]];    [_timer event:^{                CGFloat value1 = arc4random() % 101 / 100.f;        CGFloat value2 = arc4random() % 101 / 100.f;                POPSpringAnimation *strokeAnimationEnd = [POPSpringAnimation animationWithPropertyNamed:kPOPShapeLayerStrokeEnd];        strokeAnimationEnd.toValue             = @(value1 > value2 ? value1 : value2);        strokeAnimationEnd.springBounciness    = 12.f;                POPSpringAnimation *strokeAnimationStart = [POPSpringAnimation animationWithPropertyNamed:kPOPShapeLayerStrokeStart];        strokeAnimationStart.toValue             = @(value1 < value2 ? value1 : value2);        strokeAnimationStart.springBounciness    = 12.f;                POPBasicAnimation *strokeAnimationColor  = [POPBasicAnimation animationWithPropertyNamed:kPOPShapeLayerStrokeColor];        strokeAnimationColor.toValue             = (__bridge id)([self randomColor].CGColor);                [self.circleShape pop_addAnimation:strokeAnimationEnd forKey:@"layerStrokeAnimation"];        [self.circleShape pop_addAnimation:strokeAnimationStart forKey:@"layerStrokeAnimation1"];        [self.circleShape pop_addAnimation:strokeAnimationColor forKey:@"layerStrokeAnimation2"];            } timeIntervalWithSecs:1];        [_timer start];}- (UIColor *)randomColor {    return [UIColor colorWithRed:arc4random() % 101 / 100.f                           green:arc4random() % 101 / 100.f                            blue:arc4random() % 101 / 100.f                           alpha:1];}@end

 

细节

 

转载于:https://www.cnblogs.com/YouXianMing/p/4971210.html

你可能感兴趣的文章
eggs
查看>>
一步步学习微软InfoPath2010和SP2010--第七章节--从SP列表和业务数据连接接收数据(4)--外部项目选取器和业务数据连接...
查看>>
如何增强你的SharePoint 团队网站首页
查看>>
FZU 1914 Funny Positive Sequence(线性算法)
查看>>
oracle 报错ORA-12514: TNS:listener does not currently know of service requested in connec
查看>>
基于grunt构建的前端集成开发环境
查看>>
MySQL服务读取参数文件my.cnf的规律研究探索
查看>>
java string(转)
查看>>
__all__有趣的属性
查看>>
写博客
查看>>
利用循环播放dataurl的视频来防止锁屏:NoSleep.js
查看>>
python3 生成器与迭代器
查看>>
java编写提升性能的代码
查看>>
ios封装静态库技巧两则
查看>>
Educational Codeforces Round 46 (Rated for Div. 2)
查看>>
Abstract Factory Pattern
查看>>
C# 实现Bresenham算法(vs2010)
查看>>
基于iSCSI的SQL Server 2012群集测试(一)--SQL群集安装
查看>>
list 容器 排序函数.xml
查看>>
Activity启动过程中获取组件宽高的五种方式
查看>>