O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Custom View

To create a custom view, you subclass UIView and customize that subclass’s image. Create a new iOS Objective-C class (Figure 6.5).

Figure 6.5  Creating a new class

Creating a new class

On the second pane of the assistant, choose NSObject as a superclass and name the class HypnosisView. Click Create on the sheet that drops down. Then, open HypnosisView.h in the editor area. Change HypnosisView’s superclass from NSObject to UIView.

@​i​n​t​e​r​f​a​c​e​ ​H​y​p​n​o​s​i​s​V​i​e​w​ ​:​ ​N​S​O​b​j​e​c​t​
@​i​n​t​e​r​f​a​c​e​ ​H​y​p​n​o​s​i​s​V​i​e​w​ ​:​ ​U​I​V​i​e​w​

You now have a UIView subclass.

(Why didn’t we select UIView as the superclass ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required