我有一個TableView
動態原型,並且希望第一個單元格具有與其他單元格不同的背景。爲動態表格中的一個單元格設置背景
我嘗試是添加
if indexPath.row == 0 {
cell.backgroundView = UIImageView(image: UIImage(named: "firstCellBackground"))
}
在
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
這實際上是一種工作。第一個單元格獲得不同的背景,但只要我開始滾動,其他幾個單元格也會獲得背景。 :(
任何建議
不能使用半邏輯;你必須完全說明什麼後臺視圖是_every_行,因爲相同的細胞將被用於許多不同的行(其就是爲什麼你看到其他細胞獲得背景) – matt