UIBezierPath 贝塞尔曲线
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 贝塞尔曲线的更多相关文章
- 通过UIBezierPath贝塞尔曲线画圆形、椭圆、矩形
/**创建椭圆形的贝塞尔曲线*/ UIBezierPath *_ovalPath=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(, , , )]; ...
- iOS之UIBezierPath贝塞尔曲线属性简介
#import <Foundation/Foundation.h> #import <CoreGraphics/CoreGraphics.h> #import <UIKi ...
- 贝塞尔曲线(UIBezierPath)属性、方法汇总
UIBezierPath主要用来绘制矢量图形,它是基于Core Graphics对CGPathRef数据类型和path绘图属性的一个封装,所以是需要图形上下文的(CGContextRef),所以一般U ...
- iOS开发 贝塞尔曲线UIBezierPath
最近项目中需要用到用贝塞尔曲线去绘制路径 ,然后往路径里面填充图片,找到这篇文章挺好,记录下来 自己学习! 转至 http://blog.csdn.net/guo_hongjun1611/articl ...
- UIBezierPath IOS贝塞尔曲线
//记录 贝塞尔曲线使用 //根据一个矩形画曲线 + (UIBezierPath *)bezierPathWithRect:(CGRect)rect //根据矩形框的内切圆画曲线 + (UIBezi ...
- 贝塞尔曲线UIBezierPath简单使用
//常用属性 /* 1.CGPath: 将UIBezierPath类转换成CGPath 2.currentPoint: 当前path的位置,可以理解为path的终点 3.lineWidth: 线条宽度 ...
- iOS贝塞尔曲线(UIBezierPath)的基本使用方法
简介 UIBezierPath是对Core Graphics框架的一个封装,使用UIBezierPath类我们可以画出圆形(弧线)或者多边形(比如:矩形)等形状,所以在画复杂图形的时候会经常用到. 分 ...
- iOS开发 贝塞尔曲线UIBezierPath(2)
使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 . 1:UIBezierPath: UIBezierPath是在 UIKit 中 ...
- iOS开发 贝塞尔曲线UIBezierPath(后记)
使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 . 1:UIBezierPath: UIBezierPath是在 UIKit 中 ...
随机推荐
- c# 在windows服务中 使用定时器
由于最近做自动执行的程序,开始做windows服务程序, 在windows服务中如何使用定时器的时候一直失效, 以前是直接拖入timer控件,但是不能直接运行,后来在网上找了一段程序,好使了. //开 ...
- jquery cookie 用法
jquery cookie 用法 $.cookie("name","value","options") 当不设置options时,此coo ...
- BCB常用文件与字符串函数
VCL库函数简介 一.BORLAND C++ BUILDER VCL的内存管理函数 1. AllocMem 在队中分配指定字节的内存块,并将分配的每一个字节初始化为 0.函数原型如下: void * ...
- 使用phantomjs对页面进行截图
本文章参考了使用phantomjs操作DOM并对页面进行截图需要注意的几个问题 及 phantomjs使用说明 这两篇文章,初次接触phantomjs的童鞋可以去看下这两篇原文 在学习中可以看下 ph ...
- JDBC学习总结(五)
取得数据库连接是件耗时间及资源的动作,尽量利用已打开的连接,也就是重复利用取得的Connection实例,是改善数据库连接性能的一个方式,而采用连接池是基本做法.由于取得Connection的方式根据 ...
- windows本地无法启动sqlserver服务
解决方法:进入服务列表后,选择sqlserver服务,右键然后选择属性,然后在登陆选项卡中,选择本地系统帐户,这样就可以启动sqlserver服务了
- PHP输出缓冲控制- Output Control 函数应用详解
说到输出缓冲,首先要说的是一个叫做缓冲器(buffer)的东西.举个简单的例子说明他的作用:我们在编辑一篇文档时,在我们没有保存之前,系统是不会向磁盘写入的,而是写到buffer中,当buffer写满 ...
- Android新版本SDK打开旧版本项目报错解决
1.Description Resource Path Location Type Unable to resolve target 'android-19 解决:打开project.properti ...
- android4.4内核移植
01 init/目录下Kconfig修改: 956行添加: config PANIC_TIMEOUT int "Default panic timeout" help Set de ...
- Lists of network protocols
https://en.wikipedia.org/wiki/Lists_of_network_protocols Protocol stack: List of network protocol st ...