/**绘制三角形*/
CGContextRef contextRef=UIGraphicsGetCurrentContext();
CGContextMoveToPoint(contextRef, 100, 100);
CGContextAddLineToPoint(contextRef, 100, 200);
CGContextAddLineToPoint(contextRef, 200, 200);
CGContextMoveToPoint(contextRef, 100, 100);
CGContextAddLineToPoint(contextRef, 200, 200);
CGContextSetStrokeColorWithColor(contextRef, [UIColor redColor].CGColor);
CGContextStrokePath(contextRef);
/**绘制矩形*/
CGContextRef contextRef=UIGraphicsGetCurrentContext();
CGContextAddRect(contextRef, CGRectMake(50, 100, 200, 200));
CGContextSetRGBFillColor(contextRef, 1, 0, 0, 1.0);
CGContextFillPath(contextRef);
/**绘制矩形*/
CGContextMoveToPoint(contextRef, 100, 100);
CGContextAddLineToPoint(contextRef, 200, 100);
CGContextMoveToPoint(contextRef, 100, 100);
CGContextAddLineToPoint(contextRef, 100, 200);
CGContextMoveToPoint(contextRef, 100, 200);
CGContextAddLineToPoint(contextRef, 200, 200);
CGContextMoveToPoint(contextRef, 200, 100);
CGContextAddLineToPoint(contextRef, 200, 200);
CGContextStrokePath(contextRef);