Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Changing text color in Table View Cell
-
Is there any way to change the text color in Table View Cell?
-
A
TableViewCell
'stext_label
is a regularLabel
and can thus have itstext_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
-
This creates a new cell, I want to modify an existing one.
-
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.
-
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!