From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Views in playgrounds

Views in playgrounds

- [Instructor] Subclassing UI views give you a lot of control of the user interface, more than a view controller. In cases where you're building a control in Xcode, or exploring a prototype on playgrounds where view controllers are bit more unstable, subclassed UI views are a great solution. Let's take a look. In the downloads, I created a project with a playground for you. So, you can go find the project, and you'll see right at the top here, there's a playground, so I'm just going to click on the playground and go into my playground here. And I've already set some code up for you. So, we've imported UIKit and imported PlaygroundSupport. And I made two rectangle for CGRects and I made a backgroundImage which is saved into the Resources folder of the playground. So, what I'm going to do here is just create a view and then do that is just a class and we'll call it MyView and that'll be a UIView. And when you subclass UIView, there are two initializers you're going to need. The first is…

Contents