1.

UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(30, 30, 100, 100) 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(30, 30, 100, 100) cornerRadius:0];修改为

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

还可以通过

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

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

4.UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 100) 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(100, 100) radius:50 startAngle:0 endAngle:3.14159 clockwise:NO];

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

UIBezierPath 贝塞尔曲线的更多相关文章

  1. 通过UIBezierPath贝塞尔曲线画圆形、椭圆、矩形

    /**创建椭圆形的贝塞尔曲线*/ UIBezierPath *_ovalPath=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(, , , )]; ...

  2. iOS之UIBezierPath贝塞尔曲线属性简介

    #import <Foundation/Foundation.h> #import <CoreGraphics/CoreGraphics.h> #import <UIKi ...

  3. 贝塞尔曲线(UIBezierPath)属性、方法汇总

    UIBezierPath主要用来绘制矢量图形,它是基于Core Graphics对CGPathRef数据类型和path绘图属性的一个封装,所以是需要图形上下文的(CGContextRef),所以一般U ...

  4. iOS开发 贝塞尔曲线UIBezierPath

    最近项目中需要用到用贝塞尔曲线去绘制路径 ,然后往路径里面填充图片,找到这篇文章挺好,记录下来 自己学习! 转至 http://blog.csdn.net/guo_hongjun1611/articl ...

  5. UIBezierPath IOS贝塞尔曲线

    //记录  贝塞尔曲线使用 //根据一个矩形画曲线 + (UIBezierPath *)bezierPathWithRect:(CGRect)rect //根据矩形框的内切圆画曲线 + (UIBezi ...

  6. 贝塞尔曲线UIBezierPath简单使用

    //常用属性 /* 1.CGPath: 将UIBezierPath类转换成CGPath 2.currentPoint: 当前path的位置,可以理解为path的终点 3.lineWidth: 线条宽度 ...

  7. iOS贝塞尔曲线(UIBezierPath)的基本使用方法

    简介 UIBezierPath是对Core Graphics框架的一个封装,使用UIBezierPath类我们可以画出圆形(弧线)或者多边形(比如:矩形)等形状,所以在画复杂图形的时候会经常用到. 分 ...

  8. iOS开发 贝塞尔曲线UIBezierPath(2)

    使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 . 1:UIBezierPath: UIBezierPath是在 UIKit 中 ...

  9. iOS开发 贝塞尔曲线UIBezierPath(后记)

    使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 . 1:UIBezierPath: UIBezierPath是在 UIKit 中 ...

随机推荐

  1. IText 生成页脚页码

    做doc文档报表的时候可能遇到这样的需求: 每一个页面需要页码,用IText可以完成这样的需求. IText生成doc文档需要三个包:iTextAsian.jar,iText-rtf-2.1.4.ja ...

  2. 【转载】关于ActionContext.getContext().getParameters()获值问题

    ActionContext.getContext().getParameters():一个学员问题的解答 2012-11-12 15:12:05|  分类: 默认分类 |  标签:struts2   ...

  3. http://www.mxchip.com/talk/news/jishuwenzhang/2014-09-11/67.html

    http://www.mxchip.com/talk/news/jishuwenzhang/2014-09-11/67.html

  4. spring中的aware接口

    1.实现了相应的aware接口,这个类就获取了相应的资源. 2.spring中有很多aware接口,包括applicationContextAware接口,和BeanNameAware接口. 实现了这 ...

  5. Photoshop:笔刷制作和安装

    笔刷制作 1.新建一个文档,大小为要制作的笔刷大小,把画笔图像放里面 2.选择:菜单->编辑->定义画笔预设,这时在画笔面板中会出现刚定义的画笔 3.存储画笔,可以把当前的笔刷保存为一个. ...

  6. Java API —— 多线程

    1.多线程概述     1)进程:         正在运行的程序,是系统进行资源分配和调用的独立单位.         每一个进程都有它自己的内存空间和系统资源.     2)线程:         ...

  7. Java API —— 编码 & IO流( InputStreamReader & OutputStreamWriter & FileReader & FileWriter & BufferedReader & BufferedWriter )

    1.编码     1)编码表概述         由字符及其对应的数值组成的一张表     2)常见编码表         · ASCII/Unicode 字符集:ASCII是美国标准信息交换码,用一 ...

  8. SqlServer几个注意点

    1.修改系统参数时,必须是单用户情况下才能更改成功!在Properties->Options中修改. 2.数据库字段值默认是不区分大小写的,修改方法如下: 2.1.右键数据库,选择Propert ...

  9. MySQL学习笔记二

    Ø function 函数 函数的作用比较大,一般多用在select查询语句和where条件语句之后.按照函数返回的结果, 可以分为:多行函数和单行函数:所谓的单行函数就是将每条数据进行独立的计算,然 ...

  10. HDU 5313 Bipartite Graph (二分图着色,dp)

    题意: Soda有一个n个点m条边的二分图, 他想要通过加边使得这张图变成一个边数最多的完全二分图. 于是他想要知道他最多能够新加多少条边. 注意重边是不允许的. 思路: 先将二分图着色,将每个连通分 ...