-(void)drawRect:(CGRect)rect {
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 0, 0, 255, 0.1);
CGContextSetRGBStrokeColor(contextRef, 0, 0, 255, 0.5);
// Draw a circle (filled)
CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 25, 25));
// Draw a circle (border only)
CGContextStrokeEllipseInRect(contextRef, CGRectMake(100, 100, 25, 25));
// Get the graphics context and clear it
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
// Draw a green solid circle
CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(100, 100, 25, 25));
// Draw a yellow hollow rectangle
CGContextSetRGBStrokeColor(ctx, 255, 255, 0, 1);
CGContextStrokeRect(ctx, CGRectMake(195, 195, 60, 60));
// Draw a purple triangle with using lines
CGContextSetRGBStrokeColor(ctx, 255, 0, 255, 1);
CGPoint points[6] = {
CGPointMake(100, 200), CGPointMake(150, 250),
CGPointMake(150, 250), CGPointMake(50, 250),
CGPointMake(50, 250), CGPointMake(100, 200)
};
CGContextStrokeLineSegments(ctx, points, 6);
}