【问题标题】:UIImage with drawInRectUIImage 与 drawInRect
【发布时间】:2011-08-30 16:31:05
【问题描述】:

我有一个[基于窗口]的应用程序,我需要在屏幕上“绘制”一些图像,[我正在关注一个实现一些自定义图表绘图的示例项目,这样做,但它不使用 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

如何解决这个问题?

非常感谢!

【问题讨论】:

    标签: ios uiimage draw


    【解决方案1】:

    似乎在上面的例子中使用 CoreGraphics 并在 drawRect 函数中的 CGContextRef 处绘制。这可能对您有帮助: How to draw an UIImage or directly in -drawRect:?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-17
      • 1970-01-01
      相关资源
      最近更新 更多