2012-08-01 19 views

回答

0

在UIView的子视图您-drawRect方法:

CGContextRef ctx = UIGraphicsGetCurrentContext(); 
CGContextMoveToPoint(ctx, point1.x, point1.y); 
CGContextAddLineToPoint(ctx, point2.x, point2.y); 
CGContextAddLineToPoint(ctx, point3.x, point3.y); 
CGContextAddLineToPoint(ctx, point1.x, point1.y); 
CGContextClosePath(context); 
CGContextStrokePath(ctx); 
+0

如果我不希望这样做在的drawRect什么? – aherlambang 2012-08-01 21:17:36

+0

如果你想在别处做 - 你将不得不提供有效的CGContext参考 – 2012-08-01 21:58:53