0
我正在为iOS4项目使用XCode 4.0.2。如何绘制UIImageView(iOS4)
我有一个MainView.xib
和MainViewController
。
我在MainView.xib
中插入了UIImageView
的图像。
在Identity Inspector中,我给UIImageView
一个自定义的类图。
我创建了两个新文件Diagram.h
和Diagram.c
。在Diagram.m
我已经插入
- (void)drawRect:(CGRect)rect {
UIGraphicsBeginImageContext(self.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[] = {0.0, 0.0, 1.0, 1.0};
CGColorRef color = CGColorCreate(colorspace, components);
CGContextSetStrokeColorWithColor(context, color);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 200, 200);
CGContextStrokePath(context);
CGColorSpaceRelease(colorspace);
CGColorRelease(color);
}
当我运行应用程序,我可以看到图像(UIImageView
,但图纸不这样做,也许不叫,我该怎么办?
谢谢。
更详细如果删除图像,你可以看到发生在你的'drawRect'方法图纸吗?即“UIImageView”是在您的自定义绘图上绘制图像。 –
不,图像下没有绘图。 – boscarol