简体   繁体   中英

UIImage with drawInRect

i have an app [window based]that I need to "draw" some images in the screen, [Im following a sample project that implements some custom chart drawings, doing this, but it doesn't use UIImage view, just UIImage)

im using

 - (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) ];

}

but the image is not showing, label is showing fine

Im also getting this errors in console:

  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

how to fix this?

thanks a lot!

It seems that in the above examples use CoreGraphics and draws at the CGContextRef in drawRect function. May be this helps you: How to draw an UIImage or directly in -drawRect:?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM