UIBezierPath画图基础实例[画圆和椭圆]

1、圆的效果图


UIBezierPath画图基础实例[画圆和椭圆]_第1张图片

2、椭圆的效果图


UIBezierPath画图基础实例[画圆和椭圆]_第2张图片

函数代码:

#pragma mark 画圆和椭圆

/**这里偷懒一下 ,画圆和椭圆可以使用同一个方法

*可以使用+ bezierPathWithOvalInRect:方法来画圆,当我们传的rect参数是一下正方形时,画出来的就是圆。那么我们要是不传正方形,那么绘制出来的就是椭圆了。

*/

-(void)drawCiclePath{

UIBezierPath *path=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 20, self.frame.size.width-40, self.frame.size.width-40)];

/*  换成 height  就成椭圆了

UIBezierPath *path=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 20, self.frame.size.width-40, self.frame.size.height-20)];

*/

UIColor *fillColor=[UIColor purpleColor];

[fillColor set];

[path fill];

UIColor *sColor=[UIColor lightGrayColor];

[sColor set];

[path stroke];

}

你可能感兴趣的:(UIBezierPath画图基础实例[画圆和椭圆])