Swift 3 unresolved identifier CGColorGetComponents [duplicate]

给你一囗甜甜゛ 提交于 2019-12-11 07:29:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!