請問下面報錯如何解決
// Playground - noun: a place where people can play
import UIKit
let colors = [
? ? "Air Force Blue":(red: 93.0, green: 138.0, blue: 168.0),
? ? "Bittersweet":(red: 254.0, green: 111.0, blue: 94.0),
? ? "Canary Yellow":(red: 255.0, green: 239.0, blue: 0.0)
]
for (colorName,rgbColor) in colors {
? ? var color = UIColor(red: rgbColor.red, green: rgbColor.green, blue: rgbColor.blue, alpha:1.0)
}
-----------------------
xcode 6.1
Playground execution failed: <EXPR>:19:24: error: extra argument 'green' in call
UIColor 初始化參數直接寫值沒問題,傳入參數就報錯
2015-08-06
我測了下也是編不過, 要加強制類型轉換CGFloat,并且UIcolor的范圍是0-1.0,所以要除255
2014-11-28
在沒有上下文的環境下,目測這句話沒有錯。
請嘗試:
1)最好升級至xcode6.1
2)重新啟動xcode
3)確認這句代碼的上下文沒有問題(如colorStripe,vred,vgreen,vblue這些量的定義沒有問題)