I've created a tableview in swift and I'm customising appearance to make it look nicer. I'd like to change the appearance to have a clear background and white text color. Tableview function:
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;
}
So the second part works with the clear cells but but the first part doesn't for some reason. I checked out some sources online but can't seem to get this one right:
How to change text color in tableView section in swift
https://www.natashatherobot.com/ios-change-uitableviewcell-selection-color-app-wide/
Any help would be greatly appreciated! Thanks
You need to change the color of text using the "cell" object you created. So it should be like this
cell.textLabel?.textColor = UIColor.cyanColor()
Change it to any color of your desire
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With