Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically change value of Color Set in xcassets

Tags:

xcode

ios

swift

I have my iOS app's colors called out as Color Sets in an asset catalog (xcassets) file.

At runtime I'd like to be able to change the values of these Color Sets. Is this possible? and if so, how?

I've had no luck finding a way to do this.

like image 336
cmilr Avatar asked Jan 20 '18 17:01

cmilr


1 Answers

You can't change colors in an asset catalog. If you want to change those colors at runtime you need to fetch the initial colors from the asset catalog, store it somewhere else (e.g. UserDefaults) and modify those.

like image 96
D. Mika Avatar answered Nov 17 '22 10:11

D. Mika