I have a quite a few colors to add to my assets folder. They’re all in Hexadecimal form. In the Attributes inspector > Color > there is ‘Input Method‘. By default it is set to ‘Floating Point’. I know I can change this to ‘8-bit Hexadecimal’, but I’d rather not do this by hand every time I add a color. Not to mention that I’d have to do this twice per color. Once for the ‘Any’/light appearance and again for the ‘dark’.
Is there a way to change the default input method?
2
Answers
I found a small hack for changing that and I’m not sure how reliable that is:
Go to
/Applications/Xcode.app/Contents/Frameworks/AssetCatalogKit.framework/Versions/A/Resources/
Open
IBICColorSetRep.inspector
with any text editorin
<section visibleKeyPath="localContentController.selection.ibInspectedShowRGBASliders">
change:3.1.
<choice value="0" title="Floating point (0.0-1.0)">
to<choice value="2" title="Floating point (0.0-1.0)">
3.2.
<choice value="2" title="8-bit Hexadecimal">
to<choice value="0" title="8-bit Hexadecimal">
If you install a new Xcode Version you need to change it again. Best solution to that is making a backup and paste it into the same directory again after updating Xcode.
Too long to add a comment so I’m adding as an answer here:
I found a problem with the approach from @Carsten. Looks like the color value is not stored in the same representation in the
Contents.json
file when you change those constants in the inspector configuration file.Xcode stores each color in the format it was entered. So hex colors are stored like:
and floating point are stored like:
And if you make the change suggested, it stores them in the opposite representation.
This can be a problem since the rounding can be off and you could get a different color than you expect if the hex is converted to floating point and then back. Depends on the color value.
There may be more editing of the inspector files that could be done to fix this, but I’m not going to dive in right now. You never know if the Xcode codebase is using those constants and not pulling them from the file.
Safer to do the old painful way and know that your colors are accurate. 🙁