我已经快速创建了一个tableview,并且正在自定义外观以使其看起来更好。我想将外观更改为具有清晰的背景和白色文本颜色。Tableview功能:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:UITableViewCell = self.myTableView
.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
let score = scores[indexPath.row]
cell.textLabel!.text = String(score.gameScore!)
UITableViewCell.appearance().textLabel?.textColor = UIColor.whiteColor();
UITableViewCell.appearance().backgroundColor = UIColor.clearColor();
return cell;
}
Run Code Online (Sandbox Code Playgroud)
因此,第二部分使用透明单元格,但是第一部分由于某种原因而无法使用。我在网上检查了一些资源,但似乎无法正确解决这一问题:
https://www.natashatherobot.com/ios-change-uitableviewcell-selection-color-app-wide/
任何帮助将不胜感激!谢谢