Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

15. Graphics and Animations > 15.4. Drawing Images

15.4. Drawing Images

Problem

You want to be able to draw images on the screen of an iOS device.

Solution

Use the UIImage class to load an image and then use the drawInRect: method of the image to draw it on a graphics context.

Discussion

UIKit helps you draw images with ease. All you have to do is to load your images in instances of type UIImage. The UIImage class provides various class and instance methods to load your images. Here are some of the important ones in iOS:

imageNamed: class method

Loads the image (and caches the image if it can load it properly). The parameter to this method is the name of the image in the bundle, such as Tree Texture.png.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial