While Brian's answer is still correct, with the release of Swift 3, the preferred way for Swifty to do things has changed a bit.
With Swift 3, the predefined UIColors are used accordingly:
var myColor: UIColor = .white // or .clear or whatever
Therefore, if you want something like this, like the following ...
var myColor: UIColor = .myCustomColor
... then you would define the extension as follows:
extension UIColor { public class var myCustomColor: UIColor { return UIColor(red: 248/255, green: 248/255, blue: 248/255, alpha: 1.0) } }
In fact, Apple defines white as:
public class var white: UIColor
source share