20.4. Drawing Images
You want to be able to draw images on the screen of an iOS device.
UIImage class to load
an image and then use the
method of the image to draw it on a graphics context.
UIKit helps you draw images with ease. All you have to do is load
your images in instances of type
UIImage class provides various class and
instance methods to load your images. Here are some of the important
ones in iOS:
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.
Loads an image from the data encapsulated in an instance of an
NSDataobject that was passed as the parameter to this method.
initWithContentsOfFile:instance method (for initialization)
Uses the given parameter as the path to an image that has to be loaded and used to initialize the image object.
This path should be the full path to the image in the app bundle.
initWithData:instance method (for initialization)
Uses the given parameter of type
NSDatato initialize the image. This data should belong to a valid image.
Please follow these steps to add an image to your Xcode project:
Find where the image is located in your computer.
Drag and drop the image into your image category, usually named images.xcassets. Xcode will do the rest for you.
You can retrieve Xcode’s icon by following these steps:
Find the Xcode app ...