我正在加载自定义 Nib 文件以自定义UITableView的单元格。自定义 Nib 具有UILabel,该UILabel从主 View 中通过标签引用。我想知道是否可以在将单元格选择为其他颜色时更改UILabel的阴影颜色,以使其在屏幕截图中看起来不一样。

最佳答案

您可以在委托(delegate)的-tableView:willSelectRowAtIndexPath:中更改标签的阴影颜色。例如:

-(NSIndexPath*)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.textLabel.shadowColor = [UIColor greenColor];
    return indexPath;
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.textLabel.shadowColor = [UIColor redColor];
}

关于iphone - UILabel阴影来自自定义单元格选定的颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3436276/

10-13 03:51
查看更多