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

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

时间:2016-03-03 22:35:04      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

/**创建椭圆形的贝塞尔曲线*/
    UIBezierPath *_ovalPath=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 200, 100)];
    
    /**创建矩形的贝塞尔曲线*/
    UIBezierPath *_rectPath=[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 200, 100)];
    
    
    /**创建圆形的贝塞尔曲线*/
    
    UIBezierPath *_circlePath=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 100, 100)];
    UIBezierPath *_shapePath=[UIBezierPath bezierPathWithArcCenter:CGPointMake(20, 0) radius:100 startAngle:0 endAngle:3.14*2 clockwise:YES];

    /**创建带形状的图层*/
    CAShapeLayer *_shapeLayer=[CAShapeLayer layer];
    _shapeLayer.frame=CGRectMake(0, 0, 200, 100);
    _shapeLayer.position=self.view.center;
    
    /**注意:图层之间与贝塞尔曲线之间通过path进行关联*/
    _shapeLayer.path=_shapePath.CGPath;
    
    _shapeLayer.fillColor=[UIColor redColor].CGColor;
    [self.view.layer addSublayer:_shapeLayer];

 

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

标签:

原文地址:http://www.cnblogs.com/caomeinatie/p/5240094.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!