zoukankan      html  css  js  c++  java
  • CAShapeLayer

        UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];

        [self.view addSubview:showView];

        showView.backgroundColor = [UIColor redColor];

        showView.alpha = 0.5;

        

        

        

        // 贝塞尔曲线(创建一个圆)

        UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100 / 2.f, 100 / 2.f)

                                                            radius:100 / 2.f

                                                        startAngle:0

                                                          endAngle:M_PI * 2

                                                         clockwise:YES];

        

        

        

        // 创建一个shapeLayer

        CAShapeLayer *layer = [CAShapeLayer layer];

        layer.frame         = showView.bounds;                // 与showView的frame一致

        layer.strokeColor   = [UIColor greenColor].CGColor;   // 边缘线的颜色

        layer.fillColor     = [UIColor blueColor].CGColor;   // 闭环填充的颜色

        layer.lineCap       = kCALineCapSquare;               // 边缘线的类型

        layer.path          = path.CGPath;                    // 从贝塞尔曲线获取到形状

        layer.lineWidth     = 4.0f;                           // 线条宽度

        layer.strokeStart   = 0.0f;

        // 将layer添加进图层

        [showView.layer addSublayer:layer];

        // 给这个layer添加动画效果

        CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];

        pathAnimation.duration = 1.0;

        pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];

        pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];

        [layer addAnimation:pathAnimation forKey:nil];

  • 相关阅读:
    UiAutomator自动化测试框架介绍
    mongkeyrunner实现循环随机输入值的方法
    python出输出字符串方式:
    Python之字符串小代码解析
    安装JDK,Python SDK及环境变量的配置
    Monkeyrunner小脚本关于camera的使用
    ubuntu 下安装32位库 ia32-libs方法
    关于monkeyrunner的一些初步理解性的题目
    基于redis的限流
    表单防重复提交
  • 原文地址:https://www.cnblogs.com/ganeveryday/p/4980534.html
Copyright © 2011-2022 走看看