- (void)drawRect:(CGRect)rect {
//1.获得上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
/*================ 画圆 ================*/
CGContextAddArc(ctx, self.center.x, 30 + radius, radius, 0, M_PI * 2, 0);
//3.绘制到界面上
[[UIColor blackColor] set];
CGContextStrokePath(ctx);
CGContextRestoreGState(ctx);
/*================画直线=============*/
[[UIColor blackColor] set];
CGContextMoveToPoint(ctx, self.pieCenter.x, self.pieCenter.y);
CGContextAddLineToPoint(ctx, firstP.x, firstP.y);
CGContextSetLineWidth(ctx, 2);
CGContextStrokePath(ctx);
}
CGContextRef普通用法
最新推荐文章于 2019-05-31 16:11:00 发布