码迷,mamicode.com
首页 > 其他好文 > 详细

绘制贝塞尔曲线

时间:2015-01-03 11:50:39      阅读:247      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!