Search code examples
iosxcodeswift4xcode9uicolor

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"


Solution

  • 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.