From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Image and color literals

Image and color literals

- [Instructor] You've probably seen them in the auto complete Nexus, but have you ever used the image literals? Image literals pop images directly into code, without initializing the UI image. While easy, they do have their drawbacks. Let's take a look at porting code with image literals. You're most likely going to use an image literal in a Swift Playground for Ipad, so I popped one up here, and you can download this project from GitHub, and install the Swift Playground into an Ipad Playground. I've set up a simple photo background in ViewDidLoad, and we're going to add one missing line to this code, which is ImageView dot image equals and then instead of putting a UI image, you'll find at the bottom auto complete a small icon with a mountain and the sun. That's the image literal button. Go ahead and tap that, and up comes some images. You can get rid of the keyboard, and you'll see them a little better, and I'm going to go ahead and pick the first one here, which is a fish dinner…

Contents