画曲线:
- (void)drawRect:(CGRect)rect { UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(140, 40)]; //添加两个控制点 和 终点 [path addCurveToPoint:CGPointMake(40, 180) controlPoint1:CGPointMake(40, 40) controlPoint2:CGPointMake(140, 180)]; [path addCurveToPoint:CGPointMake(140, 320) controlPoint1:CGPointMake(140, 180) controlPoint2:CGPointMake(40, 320)]; [[UIColor redColor]setStroke]; [path stroke];
//绘制矩形
UIBezierPath *rectPath = [UIBezierPath bezierPathWithRect:CGRectMake(50, 50, 200, 80)]; rectPath.lineWidth = 5; [[UIColor greenColor] setStroke]; [rectPath stroke]; ```//绘制圆角矩形
UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(50, 150, 200, 80) cornerRadius:20];[roundedRect stroke];
//绘制椭圆
UIBezierPath *oval = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 250, 200, 80)];[oval stroke];
}
```