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
Literals (Images & Colors) don't work in Xcode
When you type Color Literal
, a white bo
x 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:
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))
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:
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:
Related Topics
Generate Avaudiopcmbuffer with Avaudiorecorder
Swift Class Doesn't Like Self.View.Addsubview()
Anonymous User in Realm Mobile Platform
Create Generic Delegate for Class
How to Save a Generic Measurement<Unit> in Core Data
Non Exhaustive List When Handling Errors Inside a Class Function in Swift
Swift Probability of Random Number Being Selected
Syncconfiguration Deprecated, What Is the Proper Use of Syncuser.Configuration()
Swift Codable - Parse JSON Array Which Can Contain Different Data Type
What Does This Two Question Mark Mean
(Appkit) Tab Insertion Inside of Nstextblock
Firebase Retrieve Image from Url Save with Firebase Database