請(qǐng)問下面報(bào)錯(cuò)如何解決
// 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 初始化參數(shù)直接寫值沒問題,傳入?yún)?shù)就報(bào)錯(cuò)
2015-08-06
我測(cè)了下也是編不過, 要加強(qiáng)制類型轉(zhuǎn)換CGFloat,并且UIcolor的范圍是0-1.0,所以要除255
2014-11-28
在沒有上下文的環(huán)境下,目測(cè)這句話沒有錯(cuò)。
請(qǐng)嘗試:
1)最好升級(jí)至xcode6.1
2)重新啟動(dòng)xcode
3)確認(rèn)這句代碼的上下文沒有問題(如colorStripe,vred,vgreen,vblue這些量的定義沒有問題)