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.

Type properties

Type properties

- [Instructor] You've probably used a color from UIColor, where you only needed the color. Have you ever wondered how to make your own colors? Let me show you how, and introduce you to the world of type properties. You can see an example of this in the playground I have downloaded from the exercise files. I've made a view controller with a green background. Now, what if I wanted a dark green background so I could say UIColor.darkgreen. And I can go ahead and run this and see if it actually shows me green. And it runs, and I'm going to do a Command + Option + Return. And there I get a nice big green square. I'm going to go put Command + Return to get rid of it. So we got our code back. So that's working fine. Now take a look underneath the view controller here, and you'll see another set of classes that I've set up. And it's a class called MyClass. I've instantiated it here as MyClass, and then I check the values of the…

Contents