So I’m trying to get an image to appear at a specific point. I’ve seen some stuff about drawInRect, but I’m not sure why this code isn’t working with drawAtPoint. Here is what I’m using.
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"icon.png"];
CGPoint kitty;
kitty.x = 144;
kitty.y = 144;
[image drawAtPoint:(CGPoint)kitty];
I’ve also tried this with cGPointMake and just putting the coordinates right after that. Neither method will display the image, yet neither raises an error message. What am I missing?
To get it to work I needed to make a subclass of UIView and I put this in it:
The other thing I was missing was the setNeedsDisplay method, which I used in the ViewController.m file.