Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color Literal not being suggested - Xcode 9

Im trying to set an attribute with a specific color, in this case I want to use the Color Literal function however Xcode is not suggesting Color Literal and only giving me the options to pick from UIColor... How can I fix the suggestions issue?

Color Literal not being suggested

Second Attempt with typing "L" after "Color"

like image 676
gflo Avatar asked Jan 01 '23 22:01

gflo


2 Answers

I think you can add this literal to your code snippet library.

#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
like image 116
Lumialxk Avatar answered Jan 05 '23 05:01

Lumialxk


This is possibly because the compiler does not know that you want a color. You are putting it into a dictionary and all you have told it is that it is of type Any.

Try creating the color first...

let color: UIColor = ColorLiteral

That should then pop up the picker. And you can put color into your dictionary.

like image 43
Fogmeister Avatar answered Jan 05 '23 05:01

Fogmeister