我想啓用「暗模式」功能,我的應用程序,在我的tableview細胞,我改變了textcolors像這樣如何編程修改UITableViewCells文本顏色在運行時
if ([FS isDarkModeEnabled]) {
cell.CATEGORY.textColor = [UIColor whiteColor];
cell.ORIGINUSER.textColor = [UIColor whiteColor];
cell.NUMFILES.textColor = [UIColor whiteColor];
cell.NUMTASKS.textColor = [UIColor whiteColor];
cell.SHARECOUNT.textColor = [UIColor whiteColor];
}
我想我d放回了上面的代碼進行循環,但
和
FSCategoriesTVCCell *cell2 = [self.tableView cellForRowAtIndexPath:indexPath];
for (UILabel *lbl in [cell2.contentView subviews]) {
[lbl setTextColor:[UIColor greenColor]];
}
但我無法得到它的工作。
所有上面的代碼中- tableView:cellForRowAtIndexPath:
編輯完成添加一些澄清
我知道如何手動更改文本顏色,我想要做的是循環遍歷單元格的內容和改變顏色通過for循環,而不是通過聲明每個標籤並單獨更改每個標籤。
或者,在更短的話,我想for
循環,不要做cell.Label1.textColor = blah
,您需要做的僅僅細胞.textLabel.textColor in cellForRow方法。 –
您使用的是默認的單元格textLabel還是您在單元格中聲明瞭任何標籤? –
@TejaNandamuri ive subclassed'UItableviewcell'包括7個標籤和一個imageview – highboi