Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 13 SwiftUI Color Literal missing

I am using the Xcode 13 beta and noticed the Color Literal suggestion when trying to choose a color with a picker does not show up (in previous versions I would do Color(Color Literal()) and a color picker would show up. Any thoughts on this?

like image 715
Giannis Chatziveroglou Avatar asked Jun 10 '21 16:06

Giannis Chatziveroglou


People also ask

How do you open color literals in Xcode 13?

@Stevie, try typing in a empty line #colorLiteral, upon typing ( the square icon for literal will show up.

How do you use literal color?

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 . Show activity on this post. Type #colorLiteral() and #imageLiteral() to see a color picker or image picker respectively.


Video Answer


2 Answers

Just type #colorLiteral( for color or #imageLiteral( for image and it will appear immediatly

like image 88
user3704425 Avatar answered Dec 01 '22 23:12

user3704425


Edit (September 26, 2021): As of Xcode 13.0 (13A233), color literals seem to be working now.


It's a known issue. From the release notes:

#colorLiteral, #imageLiteral, and #fileLiteral aren’t rendered. (75248191)

But other than that, note that init(_ color: UIColor) is deprecated, so you can't do something like Color(UIColor.blue). This applies to color literals too.

Instead, use the new init(uiColor: UIColor).

like image 22
aheze Avatar answered Dec 01 '22 23:12

aheze