自定义selectionStyle颜色为uitableviewcell
问题描述:
我一直在使用默认颜色灰色和蓝色的单元格选择,但我想尝试一个明亮的橙色,但我不知道如何做自定义的UITableview选择。自定义selectionStyle颜色为uitableviewcell
这是我使用此刻的代码..
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
我也曾尝试
[cell setSelectionStyle:[UIColor orangeColor]];
,但我得到一个警告说setSelectionStyle不是整数的东西。
答
你会得到该错误,因为程序期望UITableViewCellSelectionStyle
你给它一个UIColor
。我不知道是否有办法以编程方式做到这一点,但你可以尝试使用单元格的selectedBackgroundView
财产使用自己的形象:
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImageHere.png"]] autorelease];
这会去你的cellForRowAtIndexPath
方法。