I subclass UIView
, I overwrite -drawRect:
, I draw a figure by CGContext
. And now I want to fill this figure with UIImage
. Any idea how to do it?
EDIT:
My Code from -drawRect:
CGContextBeginPath(ctx);
//here I draw my figure
CGContextClosePath(ctx);
CGContextClip(ctx);
//this doesn't work
UIImage * image = [UIImage imageNamed:@"blackbackground.jgp"];
[image drawInRect:rect];
//this neither
CGImageRef cgImage = image.CGImage;
CGContextDrawImage(ctx, rect, cgImage);