-2
有沒有人遇到過這個問題?它看起來像蘋果代碼中的一個bug,如果人們同意這個代碼應該做我認爲應該做的事情,我會提交一個雷達。我不是所有熟悉CoreGraphics
色彩管理的人,因此我在提出錯誤報告之前向蘋果公司提出問題。CGColorGetComponents()不返回黑色和白色的正確值
這是直接出模板項目和唯一的非模板代碼是你在下面看到。請注意,紅色,綠色和藍色都顯示正確的元件值,但不是白色或黑色。
如果您先改變順序,例如黑白相間,然後是紅色,綠色和藍色,則問題仍然存在。
這是Swift 1.2和Xcode 6.3.1(6D1002)。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let colorComps = [
CGColorGetComponents(UIColor.redColor().CGColor),
CGColorGetComponents(UIColor.greenColor().CGColor),
CGColorGetComponents(UIColor.blueColor().CGColor),
CGColorGetComponents(UIColor.blackColor().CGColor),
CGColorGetComponents(UIColor.whiteColor().CGColor)
]
var components = [CGFloat]()
for cc in colorComps
{
for i in 0...3 { components.append(cc[i]) }
}
println("components: \(components)")
}
}
真的嗎?源代碼作爲圖像? –
我看到截圖之間差異不大。請將所有嘗試組合到一個數組中並顯示日誌。這將會更清潔。 –