2016-01-21 103 views

回答

4

這是不可能使用iOS API的。推薦的方法做,這是對separatorColor設置爲UIColor.clearColor,然後實現自己的方法是使用下面的單元格的使用setData功能:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell 
    if(condition for unique color) { 
     var bottomBorder = CALayer() 
     bottomBorder.backgroundColor = (special color) 
     bottomBorder.frame = CGRectMake(0, cell.frame.size.height - 1, cell.frame.size.width, 1) 
     cell.layer.addSublayer(bottomBorder) 
    } 
    else { 
     var bottomBorder = CALayer() 
     bottomBorder.backgroundColor = (unspecial color) 
     bottomBorder.frame = CGRectMake(0, cell.frame.size.height - 1, cell.frame.size.width, 1) 
     cell.layer.addSublayer(bottomBorder) 
    } 

    return cell 
} 

當然你也可以設置顏色來改變的基礎上,該數據細胞。

+0

確定....我不熟悉使用setData。從來沒有聽說過。你可以給我更多的細節,或者將我鏈接到我可以找到更多的地方嗎? – Schuey999

+0

當我說'setData'時,我指的是你調用的任何函數來定製單元格。你必須有一個,否則每個單元看起來都一樣。它可能不是字面上叫'setData' – danielmhanover

+0

像cellForRowAtIndex? – Schuey999

0

爲了更簡單,您可以在uitableviewcell的底部添加一個uilabel,併爲其設置約束。這是在故事板,所以它更容易 這個uilabel的框架是(0,cell.frame.size.heigh - 1,cell.frame.size.width,1)

相關問題