UILabel阴影来自自定义单元格选择的颜色 [英] UILabel shadow from custom cell selected color

查看:156
本文介绍了UILabel阴影来自自定义单元格选择的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在加载自定义nib文件来自定义UITableView的单元格。自定义笔尖有一个UILabel,可以通过标记从主视图中引用。我想知道当单元格选择为不同颜色时是否可以更改UILabel的阴影颜色,因此它看起来与截图不同。

I'm loading a custom nib file to customize the cells of a UITableView. The custom nib has a UILabel that is referenced from the main view by tag. I would like to know if it is possible to change the shadow color of the UILabel when the cell is selected to a different color so it doesn't look like in the screenshot.

推荐答案

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

You could change the label's shadow color in -tableView:willSelectRowAtIndexPath: in the delegate. For instance:

-(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];
}

这篇关于UILabel阴影来自自定义单元格选择的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆