Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access the system colors programmatically in Swift?

Tags:

ios

swift

uicolor

I'm trying to programmatically set the background color of an UIButton to the color UIColor.systemBlue, which I assume should be accessible according to the docs of UIColor and the color guidelines. However, I can only access the regular colors such as .blue and .red. In the interface builder I can select systemBlue but not programmatically.

I'm using Xcode 10.3 and building for iOS 12.4.

EDIT: I've seen the question iOS 11.x system colors, but it doesn't make sense. In the color guidelines it's clearly stated that the system color values shouldn't be hard-coded, but to use the API instead. And in the UIColor docs the system colors seem to be accessible as public class vars of UIColor.

like image 445
Benjamin Angeria Avatar asked Nov 24 '25 02:11

Benjamin Angeria


1 Answers

These system colors are only available when using the iOS 13 SDK, meaning you must use Xcode 11, not Xcode 10.3.

like image 113
TylerP Avatar answered Nov 25 '25 16:11

TylerP