-(void)drawrect:(CGRect)rect
{
这个方法不用调用,系统自己会调用
[self drawlinefor];
}
自定义一个方法
-(void)drawline
{
CGContextRef context=UIGraphicsGetCurrentContext(); 获取图形上下文
CGContextMoveToPoint ; 线起点
CGContextAddLineToPoint 线终点
CGContextSetLineWidth 线宽
[[UIColor redColor]set]; 线颜色
CGContextStrokePath(context); 渲染(只有线颜色)
CGContextFillPath(context);/ 渲染(只有填充颜色)
CGContextDrawPath 渲染(线条颜色和填充颜色)
[[UIColor grayColor]setFill]; 填充颜色
CGContextSetLineWidth 线条的粗细
CGContextAddArc 圆
CGContextAddEllipseInRect 椭圆
}