首页 > 其他 > 详细

贝赛尔曲线

时间:2015-07-08 10:53:33      阅读:275      评论:0      收藏:0      [点我收藏+]

/**

 绘图步骤

 1. 获得上下文          Ref => UIGraphicsGetCurrentContext

 2. 设置绘图路径(贝塞尔路径是UIKit封装的) UIBezierPath

 3. 将路径添加到上下文   CGContextAddPath(ctx, path.CGPath);

 4. 让上下文绘制路径     CGContextDrawPath(ctx, kCGPathStroke);

 */

//获得图形上下文

CGContextRef ctx = UIGraphicsGetCurrentContext();

 设置绘图路径(贝塞尔路径是UIKit封装的)

//画圆

UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(40, 60, 40, 40)];

//画矩形

UIBezierPath *path1 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(80, 180, 120, 60) cornerRadius:10.0];

//画线

   // 2. 贝塞尔路径

    UIBezierPath *path = [UIBezierPath bezierPath];

    // 2.1 设置起点

    [path moveToPoint:CGPointMake(10, 10)];

    // 2.2 画线

    [path addLineToPoint:CGPointMake(140, 120)];

    [path addLineToPoint:CGPointMake(270, 10)];

    // 关闭路径,从最后一个点,连接到起点,产生一条封闭的路径

    [path closePath];

 

贝赛尔曲线

原文:http://www.cnblogs.com/bluceZ/p/4629485.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!