通过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];

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM