首页 > 其他 > 详细

绘制贝塞尔曲线

时间:2015-01-03 11:49:50      阅读:221      评论:0      收藏:0      [点我收藏+]

//绘制多图形(继承UIView)

- (void)drawRect:(CGRect)rect

{

    UIColor *color =  [UIColor redColor];

    [color set];

    UIBezierPath *path = [UIBezierPath bezierPath];

    path.lineWidth = 5.0;

    //创建多边形

    [path moveToPoint:CGPointMake(100, 0)];

    //画线

    [path addLineToPoint:CGPointMake(200, 40)];

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

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

    [path addLineToPoint:CGPointMake(0, 40)];

    //封口

    [path closePath];

    //渲染

    [path fill];

  }

//绘制圆角矩形

- (void)drawRect:(CGRect)rect

{

    UIColor *color =  [UIColor redColor];

    [color set];

    //圆角矩形

    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(100, 50, 80, 80) cornerRadius:10];

    path.lineWidth = 5.0;

    //渲染

    [path fill];

    //练习:用该方法  创建一个 空心的 圆角的矩形。

    //圆角矩形

    UIBezierPath *path1 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(100, 180, 180, 80) cornerRadius:10];

    path1.lineWidth = 5.0;

    //渲染

    [path1 stroke];

}

 

 

//加载图形(继承UIViewController

- (void)viewDidLoad

{

    [super viewDidLoad];

    TRMyView *myView = [[TRMyView alloc] initWithFrame:self.view.frame];

    [self.view addSubview:myView];

}

 

//加载到主窗口(AppDelegate)

     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.window.backgroundColor = [UIColor whiteColor];

    self.window.rootViewController = [[TRRootViewController alloc] init];

绘制贝塞尔曲线

原文:http://www.cnblogs.com/mapanguan/p/4199324.html

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