Fill UIBezierPath with UIImage

I have a UIBezierpath with a circle shape:

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:100];

But then I want to fill in the UIImage circle (show only part of the image inside the circle)

Best regards Kristian

Edit:

Thanks to Daniel and Dave for the excellent answers: D saved me a lot of trouble, D

Solutions:

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddPath(ctx, path.CGPath);
CGContextClip(ctx);

and:

path.addClip;

Both work fine, but I ended up using the latter method (from Dave) because it needs less code.

+5
source share
1 answer

Update: as Dave DeLong points out, there is no need to use Core Graphics features. This should do the trick:

[path addClip];
[image drawAtPoint:CGPointZero];
+9
source

All Articles