/**創建橢圓形的貝塞爾曲線*/ 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];