折线动画、渐变色
来源:互联网 发布:淘宝怎么投诉卖家版权 编辑:程序博客网 时间:2024/04/25 07:53
//添加坐标的坐标点
UIBezierPath * pathtemp=[[UIBezierPath alloc] init];
[pathtemp moveToPoint:CGPointMake(10, 100)];
[pathtemp addLineToPoint:CGPointMake(50, 90)];
[pathtemp addLineToPoint:CGPointMake(100, 50)];
[pathtemp addLineToPoint:CGPointMake(150, 80)];
[pathtemp addLineToPoint:CGPointMake(200, 70)];
[pathtemp addLineToPoint:CGPointMake(250, 60)];
[pathtemp addLineToPoint:CGPointMake(300, 50)];
[pathtemp addLineToPoint:CGPointMake(350, 100)];
//把折线绘制到界面
CAShapeLayer *arctemp = [CAShapeLayer layer];
arctemp.path =pathtemp.CGPath; //path->CGPath;
arctemp.strokeColor = [UIColor purpleColor].CGColor;
arctemp.lineWidth = 8;
[self.view.layer addSublayer:arctemp];
//绘制线条的动画
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration= 5.0;
drawAnimation.repeatCount = 1.0;
drawAnimation.removedOnCompletion = NO;
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:10.0f];
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[arctemp addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
//===================================================================================================================
//绘制渐变色层
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame =CGRectMake(0, 0, 500, 400) ;// self.view.frame;
gradientLayer.colors = @[(__bridge id)[UIColor colorWithRed:249.0/255.0 green:127.0/255.0 blue:127.0/255.0 alpha:1].CGColor ,
(__bridge id)[UIColor colorWithRed:250.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1].CGColor,
(__bridge id)[UIColor yellowColor].CGColor];
gradientLayer.locations=@[@0.0,@0.2,@1.0];
gradientLayer.startPoint = CGPointMake(0.5,0.5);
gradientLayer.endPoint = CGPointMake(0.5,1);
[self.view.layer addSublayer:gradientLayer];//加上渐变层
//============第一种方式添加路径->这个是绘制渐变需要的
UIBezierPath * path=[[UIBezierPath alloc] init];
[path moveToPoint:CGPointMake(10, 100)];
[path addLineToPoint:CGPointMake(10, 300)];
[path addLineToPoint:CGPointMake(350, 300)];
[path addLineToPoint:CGPointMake(350, 100)];
[path addLineToPoint:CGPointMake(300, 50)];
[path addLineToPoint:CGPointMake(250, 60)];
[path addLineToPoint:CGPointMake(200, 70)];
[path addLineToPoint:CGPointMake(150, 80)];
[path addLineToPoint:CGPointMake(100, 50)];
[path addLineToPoint:CGPointMake(50, 90)];
[path closePath];
//============第二种方式添加路径
// UIBezierPath* path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(10,10,100,100)];
//============第三种方式添加path路径
//CGMutablePathRef path = CGPathCreateMutable();
//
//CGPathAddRect(path, nil, CGRectInset(self.view.bounds, 20, 120));
CAShapeLayer *arc = [CAShapeLayer layer];
arc.path =path.CGPath;
arc.fillColor = [UIColor yellowColor].CGColor;
arc.strokeColor = [UIColor yellowColor].CGColor;
arc.lineWidth = 1;
gradientLayer.mask=arc;//用折现裁剪gradientLayer
- 折线动画、渐变色
- iOS 折线图实现,虚线,渐变色填充,线条动画
- iOS 带渐变背景动画的折线统计图
- swift 自定义画渐变色折线图
- 折线图以及渐变
- echarts折线图颜色渐变
- 背景及文字渐变色闪烁动画
- iOS 折线图动画
- Android自定义折线图和曲线图(曲线被渐变色填充)
- 解决折线图动态渐变-感悟
- Achartengine折线图实现背景渐变效果
- 折线图中如何填充渐变颜色
- 自定义View之颜色渐变折线图
- 自定义View之颜色渐变折线图
- 动画特效八:渐变动画
- Android 动画 - AlphaAnimation渐变动画
- as3 文本渐变动画
- JS 颜色渐变动画
- 【ASP.NET】Webform与MVC开发比较
- js中push()的用法
- 高性能网站架构之负载均衡 Nginx+tomcat+redis实现tomcat集群
- js兼容性
- Qt中读写Excel
- 折线动画、渐变色
- java.lang.NoSuchFieldException: resourceEntries
- cc-day
- EJS学习总结
- 从头到尾写SQL(五)
- Linux版本openoffice4.1.2和SwfTools的安装(CentOS6.5-6.7)
- leetcode Longest Increasing Path in a Matrix
- 欢迎使用CSDN-markdown编辑器
- windows apache 服务 监控重启脚本