代碼報(bào)錯(cuò)的進(jìn),希望能幫到你
import UIKit
let colors =
[
? ? "A":(red:93,green:138,blue:168),
? ? "B":(red:254,green:111,blue:94),
? ? "C":(red:255,green:239,blue:0),
? ? "D":(red:255,green:140,blue:0),
? ? "E":(red:143,green:0,blue:255),
? ? "F":(red:113,green:188,blue:120),
? ? "G":(red:228,green:155,blue:15),
? ? "H":(red:244,green:0,blue:161),
? ? "I":(red:252,green:247,blue:94),
? ? "J":(red:165,green:11,blue:94)
]
var backView=UIView(frame:CGRect(x: 0.0, y: 0.0, width: 320.0, height: Double(colors.count * 50)))
backView.backgroundColor=UIColor.black
backView
var index=0
for (colorName,rgbTuble) in colors
{
? ? var colorStripe=UILabel(frame:CGRect(x: 0.0, y: Double(index*50+5), width: 320.0, height: 40.0))
? ? colorStripe.backgroundColor =
? ? ? ? UIColor(
? ? ? ? ? ? red: CGFloat(rgbTuble.red)/255.0,
? ? ? ? ? ? green: CGFloat(rgbTuble.green)/255.0,
? ? ? ? ? ? blue: CGFloat(rgbTuble.blue)/255.0,
? ? ? ? ? ? alpha: 1.0
? ? )
? ? var colorNameLabel=UILabel(frame: CGRect(x: 0.0, y: 0.0, width: 300.0, height: 40.0))
? ? colorNameLabel.font = UIFont(name:"Arial", size: 24.0)
? ? colorNameLabel.textColor = UIColor.black
? ? colorNameLabel.textAlignment = NSTextAlignment.right
? ? colorNameLabel.text = colorName
? ? colorStripe.addSubview(colorNameLabel)
? ? backView.addSubview(colorStripe)
? ? index+=1
}
backView
UIColor.black 現(xiàn)在是一個(gè)屬性值,不是方法
CGRectMake() - > CGRect()