Bronze Challenge: Draw an Image

The challenge is to load an image from the filesystem and draw it on top of the concentric circles, as in Figure 4.21.

Figure 4.21  Drawing an Image

Drawing an Image

Find an image file. A PNG with some transparent parts would be especially interesting. (The zip file you downloaded has logo.png that will work nicely.) Drag it into your Xcode project.

Creating a UIImage object from that file is one line:

U​I​I​m​a​g​e​ ​*​l​o​g​o​I​m​a​g​e​ ​=​ ​[​U​I​I​m​a​g​e​ ​i​m​a​g​e​N​a​m​e​d​:​@​"​l​o​g​o​.​p​n​g​"​]​;​

In your drawRect: method, compositing it onto your view is just one more:

[​l​o​g​o​I​m​a​g​e​ ​d​r​a​w​I​n​R​e​c​t​:​s​o​m​e​R​e​c​t​]​;​
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset