Xcode 8 features
Remarks[edit | edit source]
This only works with projects using Swift 3+
Color and image literals[edit | edit source]
Xcode 8 will automatically recognize any images youâve got in an Asset Catalog and offer them up as a suggestion inside of a UIImage initializer.
So you could basically declare a new variable and then add an asset name that you have added to your asset catalog. For example
let img = dog.
img does now contain the image of
dog thatÂ´s in the asset catalog.
Under the hood itâs creating code that looks like this: #imageLiteral(resourceName: "dog.png"). But inline in the source editor, youâll just see the file name of the image.
So you could do this now
imageView.image = img.
Note that you need to click on the instellisense suggestion so that you see a thumbnail of the image in the code and then the image name.