一些内置颜色让我很困惑:
let color = UIColor.blackColor()
let colorComponents = CGColorGetComponents(color.CGColor)
let red = colorComponents[0]
let green = colorComponents[1]
let blue = colorComponents[2]
let alpha = colorComponents[3]
print("red: \(red)\ngreen: \(green)\nblue: \(blue)\nalpha: \(alpha)")
我得到了
红色:0.0
绿色:1.0
蓝色:2.41104035170528e-321
alpha:4.94065645841247e-324
不应该是红色:0,绿色:0,蓝色:0,alpha:1 ?
当我使用whiteColor()
时,我得到了
红色:1.0
绿色:1.0
蓝色:2.184138553679e-314
alpha:2.19371200885718e-314
不应该红色:1,绿色:1,蓝色:1,alpha:1 ?
我使用Xcode 7.3.1,Swift 2.2