user8818243
user8818243

Reputation:

Literals (Images & Colors) don't work in Xcode

When I try using literals in a Playground, it shows me like this (doesn't show my image):

anotherExample in above i add image or UIImage literal but doesn't show their contents.\

and also this with colors (I can't even see colors):

another example

Upvotes: 6

Views: 25939

Answers (3)

PGDev
PGDev

Reputation: 24341

When you type Color Literal, a white box appears. In order to set the required colour, tap on that white box to select the colour from Color Picker.

This is what it looks like:

enter image description here

Upvotes: 15

Esmaeil
Esmaeil

Reputation: 658

Type #colorLiteral() and #imageLiteral() to see a color picker or image picker respectively.

color literal or image literal in xcode placeholder

Note: Image picker will list your images at Assets.xcassets.

Upvotes: 26

Badr Bujbara
Badr Bujbara

Reputation: 8671

Make sure you add to the class import UIKit

Upvotes: 6

Related Questions