Programmatically:
From http://www.iphoneexamples.com/ :
CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f); UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; [myImage setImage:[UIImage imageNamed:@"myImage.png"]]; myImage.opaque = YES;
Where myImage.png is a png image that you import into your resources folder.
Using Nib (Xib file):
- Open your.xib file.
- Go to Tools → Library.
- Drag one UIImageView onto your .xib.
- Open the Attribute Inspector ImageView (press Cmd + 1).
- You will get one Image property. Select the desired image from the Resources folder in the drop-down list.
- There you have it. :-)
source share