2012-08-01 34 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