我有一个 UIImage
,我想在 UIView
上绘制它。但我不想创建 UIImageView
并将其添加为 subview ,而是想覆盖 -drawRect:
并直接绘制我的 UIView。
例如,我的代码如下所示:
- (void)drawRect:(CGRect)rect {
CGContextRef myContext = UIGraphicsGetCurrentContext();
UIImage *img = [UIImage imageNamed:@"foo.png"];
// how to draw the directly into the view now?
}
最佳答案
调用[img drawInRect:rect];
。
关于iphone - 如何绘制UIImage或者直接在-drawRect中绘制 :?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1663815/