- (void)drawRect:(CGRect)rect 2 { 3 //画圆,以便以后指定可以显示图片的范围 4 //获取图形上下文 5 CGContextRef ctx=UIGraphicsGetCurrentContext(); 6 CGContextAddEllipseInRect(ctx, CGRectMake(100, 100, 50, 50)); 7 8 //指定上下文中可以显示内容的范围就是圆的范围 9 CGContextClip(ctx); 10 UIImage *image2=[UIImage imageNamed:@"me"]; 11 [image2 drawAtPoint:CGPointMake(100, 100)]; 12 }
显示:
![](http://images.cnitblog.com/i/450136/201406/111901492333642.png)