2:贝塞尔曲线

内接矩形,bezierPathWithRect:

    [[UIColor redColor]setStroke];
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 150, 150)];
    path.lineWidth = 5;
    path.lineCapStyle = kCGLineCapRound;
    
    [path stroke];

内接圆角矩形(可画圆)bezierPathWithRoundedRect:cornerRadius:

// 正方形极限是内接圆,长方形极限是内接椭圆    
[[UIColor greenColor]setFill];
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 150, 150) cornerRadius:75];
    path.lineWidth = 1;
    
    [path fill];

内接圆角+锐角矩形 bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:

   // 设置线的填充色
    [[UIColor greenColor] setStroke];
   // 新建一个bezier对象,此对象用于绘制一个部分圆角的矩形,左上、右下
    UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 10, 280, 280)
                                                     byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight
                                                           cornerRadii:CGSizeMake(10, 10)];
    // 设置线宽度
    bezierPath.lineWidth = 10;
    // 开始绘制
    [bezierPath stroke];

内接圆 bezierPathWithOvalInRect:

内接圆弧 bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:

  • radius圆半径
  • startAngle = 0 从圆心直角坐标系(radius,0)坐标开始
  • clockwise = YES 顺时针绘制
  • endAngle M_PI = 180度 , M_PI_2 = 90度,角度为顺时针角度,逆时针绘制时,绘制的是逆时针部分,例如M_PI_2绘制的就是逆时针的180 + 90度

CGRectInset

     frame = (100,100,50,50)
     x = 10;
     y = 10;
     result = CGRectInset(frame, x, y);
     result = (100 - x, 100 - y,50 - x * 2, 50 - y * 2);
// 根据一个点和半径,创建这个圆的贝塞尔曲线
[UIBezierPath bezierPathWithOvalInRect:CGRectInset(point.frame, -radius, -radius)]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容