XCode 6.1 was one of the finalists of the Dr. Dobb’s Jolt Awards 2015: Coding Tools. The Playground introduced in XCode 6 is extremely useful to easily test your Swift code snippets.
However, there is some confusion about the possibility of working with some UIKit classes and check the results in the Playground.
You can create instances of many UIKit classes in the Playground and check the results at the right-hand side of your code snippets. In this case, I’ll provide you an example of how to create UIImage, CGRectMake, and UIButton instances. Then, I will set a title for the button, change the title’s color and finally set a background image.
After you create a new Swift Playground that targets iOS in XCode, select View | Utilities | Show File Inspector. Check the value for Resource Path below Playground Settings. In my case, the Resource Path is /Users/gaston/Documents/GastonHillarPlayground.playground/Resources. Thus, if you want to load an image within the Playground, just copy it to the folder specified in Resource Path. In my case, I just want to load an up arrow image, and therefore, I copy Arrow-Phone.png to the /Users/gaston/Documents/GastonHillarPlayground.playground/Resources folder.
Then, you can enter the following code and use either the Quick View eye or the Circle with the Plus (+) sign to check the visual results.