There is -drawAtPoint: method in UIImage, if I understand the question.
If you have a UIView and need to set an image as a background, this code will help:
UIColor* bKColor = [[UIColor alloc] initWithPatternImage[UIIma
ge imageNamed: @"MyBkgnd.png"]];
self.view.backgroundColor = bkColor;
[bkColor release];
If you need to draw something in a view, you can use drawInRect: method.
In the view .m file you usually have:
- (id)initWithFrame:(CGRect)
frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}
- (void)drawRect:(CGRect)rec
t {
// Drawing code
}
In the initWithFrame you can initialize the image and in drawInRect draw it.
For example so:
- (void)drawRect:(CGRect)rec
t {
CGContextRef context = UIGraphicsGetCurrentContex
t();
UIImage *myImage = [UIImage imageNamed:@"anImage.jpg"]
;
CGPoint imagePoint = CGPointMake(10, 10);
[myImage drawAtPoint:imagePoint];
[myImage release];
}
Do you see the following line: [myImage drawAtPoint:imagePoint]; ?
it draws the image at point 10, 10.
I can recommend you this tutorial:
iPhone SDK: Learning About Touch Events & Basic Game Animation
http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-learning-about-touch-events-basic-game-animation/