Book Image

Swift Cookbook

Book Image

Swift Cookbook

Overview of this book

Table of Contents (18 chapters)
Swift Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Stretching an image


Sometimes, it's necessary to have more than one sample of a picture in order to see which ratio is the desired one. Let's imagine that we have a message, but we don't want to show it to the user; we only want to show something that gives him an idea that there is something and the application will show the correct ratio later.

For cases like these, you can use UIImage and ImageView, and visualize it on the playground.

Getting ready

Create a new playground called Chapter 6 Stretching Image and also have an image ready for this recipe. I would recommend that you download the image file secret_message.png that is included with the resource files of this book.

How to do it...

To create a playground that stretches an image, follow these steps:

  1. Close the Xcode and open a Finder window, go to the folder where you saved the playground, click on the project that you created, and right-click (or control-click) on it. On the menu, choose the option Show Package Contents, as we learned...