I am setting a label colour in a view controller class. When I use the following code, it works.
self.labelTest.textColor = UIColor.red
However, if I use the initializer of UIColor, like the following, the label becomes "invisible".
self.labelTest.textColor = UIColor(red: 1, green: 0, blue: 0, alpha: 0)
Can someone tell me why this is so?
It is because you have set alpha to 0
self.labelTest.textColor = UIColor(red: 1, green: 0, blue: 0, alpha: 0)
set alpha to 1 in order to make it visible
self.labelTest.textColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1)
alpha
The opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.