I have an UIImage
which I want to draw on a UIView
. But instead of creating an UIImageView
and adding this as a subview, I want to overwrite -drawRect:
and draw my UIView directly.
For example, my code looks like:
- (void)drawRect:(CGRect)rect {
CGContextRef myContext = UIGraphicsGetCurrentContext();
UIImage *img = [UIImage imageNamed:@"foo.png"];
// how to draw the directly into the view now?
}
Call [img drawInRect:rect];
.