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

/**创建椭圆形的贝塞尔曲线*/
    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];

 

posted @ 2015-04-01 14:22  曹县三胖暴打大猩猩  阅读(7133)  评论(0编辑  收藏  举报