DrawRect is not displaying the image
In my Application am trying to display an image in a rectangle and am using DrawRect method.The problem is at the output am seeing nothing.Only blank screen in simulator.Here is the co开发者_Go百科de:
- (void)viewDidLoad {
[super viewDidLoad];
[self drawRect:CGRectMake(78, 43, 222, 138)];
}
- (void)drawRect:(CGRect)rect {
UIImage *myImage = [UIImage imageNamed:@"btbp.jpg"];
CGRect imageRect = CGRectMake(10, 10, 300, 400);
[myImage drawInRect:imageRect];
//[self setNeedsDisplay];
[myImage release];
}
there is no effect in invoking drawRect. instead you should invoke setNeedsDisplay to enforce redrawing.
精彩评论