zoukankan      html  css  js  c++  java
  • CAShapeLayer使用

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

        [self.view addSubview:showView];

        showView.backgroundColor = [UIColor whiteColor];

        

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

                                                            radius:100 / 2.f

                                                        startAngle:0

                                                          endAngle:1.5*M_PI

                                                         clockwise:YES];

        

        CAShapeLayer *layer = [CAShapeLayer layer];

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

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

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

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

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

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

        layer.strokeStart   = 0.0f;

        layer.strokeEnd     = 0.0f;

        

        [showView.layer addSublayer:layer];

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

        pathAnimation.duration = 5.0;

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

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

        [layer addAnimation:pathAnimation forKey:nil];

  • 相关阅读:
    (OK) error: code model kernel does not support PIC mode
    compile android for x86_64
    内核开发的前途在什么地方,发展方向有哪些?
    SOA 与 MSA(微服务架构)
    [Android] adb命令如何获取android手机屏幕分辨率
    (2) 在 Build 系统中添加新的内容
    (1) 理解 Android Build 系统
    (OK) [solved] error
    Error while building CM 13 (KERNEL_OBJ/usr, needed by libtinyalsa_intermediates/mixer.o)
    (OK) http://www.android-x86.org
  • 原文地址:https://www.cnblogs.com/feng9exe/p/6731304.html
Copyright © 2011-2022 走看看