我想更改 TableView 中特定单元格的标签颜色(通过代码)。问题是我想使用一个动态单元格,这导致每个单元格中的每个标签都会改变它们的颜色。这可能吗?我真的很感激一些帮助。这是在带有 Swift 的 xcode 中。
最佳答案
在您的 UITableViewDataSource
中,您可以使用 tableView:cellForRowAtIndexPath:
更新位于特定 indexPath
的单元格,例如
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:YourCellIdentifier forIndexPath:indexPath]
if ([indexPath isEqual:theSpecificIndexPath]) {
cell.label.textColor = ...;
}
}
关于ios - 更改动态 TableView 中的特定单元格,Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35874570/