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