我有一个应用程序[基于窗口],我需要在屏幕上“绘制”一些图像,[我跟随一个实现一些自定义图表绘图的示例项目,这样做,但它不使用UIImage视图,只是的UIImage)
我正在使用
- (void)viewDidLoad { [super viewDidLoad];
self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
self.view.backgroundColor = [UIColor grayColor];
UILabel *labelA = [[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 20)]autorelease];
[self.view addSubview: labelA];
labelA.text = @"mk ss9";
[MyClassic pongalo];
int i = [MyClassic numero];
NSLog(@"el nuro :%d",i);
[MyClassic suma1:343];
int y = [MyClassic sumatoria:11 :12];
NSLog(@"suma = %d",y);
[self dicto];
UIImage *img = [UIImage imageNamed:@"line.png"];
[img drawInRect: CGRectMake(12, 12, 12, 200) ];
}
但图片未显示,标签显示正常
我也在控制台中收到此错误:
CGContextSaveGState: invalid context 0x0
CGContextSetBlendMode: invalid context 0x0
CGContextSetAlpha: invalid context 0x0
CGContextTranslateCTM: invalid context 0x0
CGContextScaleCTM: invalid context 0x0
CGContextDrawImage: invalid context 0x0
CGContextRestoreGState: invalid context 0x0
如何解决这个问题?
非常感谢!
答案 0 :(得分:1)
似乎在上面的例子中使用了CoreGraphics并在drawRect函数中绘制了CGContextRef。可能这会对你有所帮助: How to draw an UIImage or directly in -drawRect:?