How to Turn Off Color Literals in Xcode

How to turn off color literals in Xcode?

I doubt that there is a setting.

This is more a workaround than a solution:

⌘C the color square – which copies the text –  and paste it as comment

Sample Image

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

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:

Sample Image

Can I use color literals in SwiftUI

Note: From Xcode 11 Beta 5, Color has an initializer for this already and no need to implement it.

So you can use colorLiteral like this:

Color(#colorLiteral(red: 1, green: 0, blue: 0, alpha: 1))

preview

Or any other CGColor, UIColor (or NSColor for macOS):

Color(.red)

Color Literal not being suggested - Xcode 9

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.

What is the correct way to update RGB values of a colorLiteral in Xcodet?

Double click on the little square, this will pop up:

Sample Image

press "Other". The usual macOS color picker shows up. You can then go to the second tab, and select the RGB sliders option. There is also an option to enter floating point values if you click on the gear icon:

Sample Image



Related Topics



Leave a reply



Submit