我有一個ViewController和一個TableView。
通過代碼,我填充TableView的單元格和其他代碼,我設置單元格的BackgroundColor。
注 - 在代碼的其他部分我這樣做
cell.backgroundColor = UIColorFromRGB(0xAA66CC) //雖然每個單元格的具體RGB值會有所不同。iOS Swift - 從選定的TableView中獲取BackgroundColor單元
現在在我的Segue到另一個視圖我想檢索,不僅「名稱」元素,而且單元格的BackgroundColor並將其發送到下一個ViewController。
我得到的「名稱」很好,但我不知道如何獲得BackgroundColor值(我將需要轉換爲字符串傳遞)。
我Segue公司代碼:
override func prepareForSegue(segue: UIStoryboardSeque, sender: AnyObject?)
{
if segue.identifier = "GoToNextVC" {
if let cell = sender as? UITableViewCell {
let destination = segue.destinationViewController as! NextVC
let indx = tableView.IndexPathForCell(cell).row
destination.SelectedValue = self.peripherals[indx].name // This works fine.
destination.SelectedColor = **< I don't know what to do here >**
}
}
}
該代碼工作得到SelectedObject名稱,但我不知道怎麼去Cell的BACKGROUNDCOLOR這樣我就可以再通過Segue公司傳遞。
您的協助將不勝感激。
不是我已經嘗試過,但有明顯的錯誤:'cell.backgroundColor'? –
嘗試cell.contentView.backgroundColor –