Is there any way to change the text color in Table View Cell?
Forum Archive
Changing text color in Table View Cell
techteej
Oct 27, 2014 - 03:42
dgelessus
Oct 24, 2014 - 13:35
A TableViewCell's text_label is a regular Label and can thus have its text_color changed:
class MyDataSource(object):
def tableview_cell_for_row(self, tv, section, row):
cell = ui.TableViewCell()
cell.text_label.text_color = (1.0, 0.0, 0.0, 0.0)
cell.text_label.text = "I am red"
return cell
techteej
Oct 27, 2014 - 01:08
This creates a new cell, I want to modify an existing one.
polymerchm
Oct 27, 2014 - 03:42
Here's a snippet of code in my flashcard program. highlight is a global that corresponds to the row needing highlighting in the items for the tableview.
def tableview_cell_for_row(self, tableview, section, row):
# Create and return a cell for the given section/row
cell = ui.TableViewCell()
cell.text_label.text = self.items[row]['title']
if row == highlight:
cell.text_label.text_color = 'red'
cell.accessory_type = self.items[row]['accessory_type']
return cell
I also set a checkmark on this cell. Remember, this is called every time cell appears on the screen. As when it scrolls into view.
vcr80
Mar 13, 2016 - 13:38
Is there a tutorial on how to create custom TableViewCells (with multiple subviews like labels, images, etc.) and then populate them with data?
Ah - https://forum.omz-software.com/topic/1922/adding-a-label-to-tableviewcell-it-s-offset-by-one - seems to be a good starting point!