Displaying an Image

After an instance of UIImage is available, there are a few ways to display it in the user interface. The first is UIImageView. When an instance of UIImageView is available, it has a property called image that can be set:

[self.sourceImageView setImage:scaleImage];

UIImageView can also be instantiated with an image, which will set the bounds to the size of the image:

UIImageView *newImageView =[[UIImageView alloc] initWithImage:myImage];

For images displayed in a UIImageView, setting the contentMode can have interesting and useful effects on how the image is displayed, as shown in Figure 19.1.

Figure 19.1 Sample app: content mode effects.

The content mode setting ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.