zoukankan      html  css  js  c++  java
  • UIBezierPath 贝塞尔曲线

    1.

        UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(3030100100) cornerRadius:0];

        CAShapeLayer * layer = [CAShapeLayer layer];
        layer.path = path.CGPath;
        layer.fillColor = [[UIColor blackColor]CGColor];

        layer.strokeColor = [[UIColor orangeColor] CGColor];    

        [self.view.layer addSublayer:layer];

      从下图可以看出,这个layer是一个矩形,那是因为 cornerRadius赋值为0

    本文转自 张江论坛  张江家园网  http://www.999dh.net/home.php?mod=space&uid=1&do=blog&id=370  转载请注明  

    2.UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(3030100100) cornerRadius:0];修改为

       UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(3030100100) cornerRadius:30];后,得到的结果是

      

    还可以通过

    layer.lineCap = kCALineCapRound;
    layer.lineWidth = 3.0f;
    来指定stroke的宽度以及各式。

    3 .[UIBezierPath bezierPathWithArcCenter:CGPointMake(100100) radius:50 startAngle:0 endAngle:2*3.14159 clockwise:YES];
        是以 100,100为中心点,以50为半径,的一个圆(角度从0到2*PI)  clockwise表示顺时针。

    4.UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100100) radius:50 startAngle:0 endAngle:3.14159 clockwise:NO];

        CAShapeLayer * layer = [CAShapeLayer layer];

        layer.path = path.CGPath;

        layer.fillColor = [[UIColor blackColor]CGColor];

        layer.strokeColor = [[UIColor orangeColor] CGColor];

        layer.lineCap = kCALineCapRound;

        layer.lineWidth = 3.0f;

        [self.view.layer addSublayer:layer];

     

      运行入下图
      UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100100) radius:50 startAngle:0 endAngle:3.14159 clockwise:NO];

       从0到一个PI,方向是逆时针,所以就是上半个圆形。

       

  • 相关阅读:
    GC算法 垃圾收集器
    JVM内存结构
    java类的加载机制
    Spring Boot:Web 综合开发
    构建微服务:Spring boot 入门篇
    Spring Boot:Spring Boot 中 Redis 的使用
    Spring Boot:Thymeleaf 使用详解
    Android ActionBar完全解析,使用官方推荐的最佳导航栏(下)
    用ActionBar的ActionProvider的时候报错:cannot be cast to android.view.ActionProvider
    百度图片API
  • 原文地址:https://www.cnblogs.com/rollrock/p/3844768.html
Copyright © 2011-2022 走看看