Swift 3未解析的标识符CGColorGetComponents

时间:2016-08-11 14:51:00

标签: uicolor swift3 cgcolor

如何在Swift 3中重构此代码?:

    extension UIColor {
        var hexString: String {
            // Produces "Use of unresolved identifier 'CGColorGetComponents'"
            let components = CGColorGetComponents(self.cgColor)
            ....
        }
    }

1 个答案:

答案 0 :(得分:2)

var r:CGFloat = 0, g:CGFloat = 0, b:CGFloat = 0, a:CGFloat = 0
self.getRed(&r, green: &g, blue: &b:, alpha: &a)
...