UIColor.blueColor static property
The UIColor.blueColor static property is a fixed color: rgb(0, 0, 255), blue. Its value doesn't change between Light Mode and Dark Mode.
You don't need it in everyday code: write the string 'blue' directly to a color property for the same effect.
Value
UIColor.
- Read-only. Assigning to it throws
TypeError. - Reading it always returns the same object:
UIColor.blueColor === UIColor.blueColoristrue. - Assigning it to a color property has the same effect as writing
'blue'. It reads back as the string'blue', not aUIColorobject. Reading back'blue'after writing it to a color property goes through the same code as the other color names and is not individually verified in the simulator. - The value comes from Apple's definition, converted to 0–255 and rounded.
Examples
js
const box = new UIView();
box.backgroundColor = UIColor.blueColor;
console.log(box.backgroundColor);Result: The console prints blue. The on-screen color is not verified in the simulator.
Corresponding iOS API
UIColor.blueColor. In Swift the name is UIColor.blue, which matches the color name string here.