问题
How can I refactor this code in Swift 3?:
extension UIColor {
var hexString: String {
// Produces "Use of unresolved identifier 'CGColorGetComponents'"
let components = CGColorGetComponents(self.cgColor)
....
}
}
回答1:
var r:CGFloat = 0, g:CGFloat = 0, b:CGFloat = 0, a:CGFloat = 0
self.getRed(&r, green: &g, blue: &b:, alpha: &a)
...
来源:https://stackoverflow.com/questions/38899725/swift-3-unresolved-identifier-cgcolorgetcomponents