在qq中,可以看到头像是圆形显示的,通过CGContextClip可以设置
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextAddEllipseInRect(context, CGRectMake(100, 100, 100, 100));
CGContextClip(context);
UIImage *img=[UIImage imageNamed:@"img.jpg"];
[img drawAtPoint:CGPointMake(100, 100)];
CGContextRef context=UIGraphicsGetCurrentContext();
UIImage *img=[UIImage imageNamed:@"img.jpg"];
CGContextMoveToPoint(context, 30, 120);
CGContextAddLineToPoint(context, 50, 200);
CGContextAddLineToPoint(context, 200, 60);
CGContextClosePath(context);
CGContextClip(context);
[img drawAtPoint:CGPointMake(30, 120)];