2016-08-11 3 views
1

Как реорганизовать этот код в Swift 3 ?:Swift 3 неразрешенные CGColorGetComponents идентификатор

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

Это должно быть 'cgColor.components', хотя это не будет работать, как из Xcode 8 бета-4 , [см. этот вопрос и ответы] (http://stackoverflow.com/questions/38769322/xcode-8-beta-4-cgcolor-components-unavailable) для получения дополнительной информации. – Hamish

+0

Вы можете использовать метод getRed apple-reference-documentation: // hsPr9ZXOsl –

ответ

1
var r:CGFloat = 0, g:CGFloat = 0, b:CGFloat = 0, a:CGFloat = 0 
self.getRed(&r, green: &g, blue: &b:, alpha: &a) 
... 
Смежные вопросы