2015-05-14 143 views
0

我想改变tablecell的背景颜色。 这里是代码:自定义UITableViewCell背景颜色

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    var cell = tableView.dequeueReusableCellWithIdentifier("FirstMainViewTableCells") as! FirstMainViewTableCell 

    cell.backgroundColor = UIColor(red: 43, green: 65, blue: 87, alpha: 1) 

    return cell 
} 

这里是结果:

Screenshot

但它与UIColor.blackColor()和作品的UIColor。颜色:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    var cell = tableView.dequeueReusableCellWithIdentifier("FirstMainViewTableCells") as! FirstMainViewTableCell 

    cell.backgroundColor = UIColor.blackColor() 

    return cell 
} 

Second Screenshot

你能帮助我吗?

+2

我得到403错误页面,不能查看您的保管箱。 –

+0

@ Dato'MohammadNurdin我们甚至不需要链接,它明显的背景是黑色的。 – Arbitur

回答

3

颜色在iOS中介于0-1之间。您需要添加的因素得到正确的颜色代码,请参阅下面

cell.backgroundColor = UIColor(red: 43/255.0, green: 65/255.0, blue: 87/255.0, alpha: 1); 

它应该工作。

干杯。

+0

哦,非常感谢,我忘了它。现在它工作正常。 – dsk1306

+0

@iphonic ...正确答案。 –

相关问题