这个是在自定义cell里弄的:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.selectedBackgroundView = [[[UIView alloc] initWithFrame:self.bounds] autorelease];
self.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2f];
self.accessoryType = UITableViewCellAccessoryNone;
转载自:http://blog.youkuaiyun.com/likendsl/article/details/7776437
1.改变UITableViewCell选中时背景色
- cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
- cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];
2.自定义UITableViewCell选中时背景
- cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];
3. 字体颜色
- cell.textLabel.highlightedTextColor = [UIColor xxxcolor];
4.清楚grouped-style的背景
UITableViewCell的文档中描述,backgroundView在plain-style的TableView里面是nil,在grouped-style的TableView里面并不是空的,有一个系统的默认值,所以这里置空一下就ok了。
- UIView *tempView = [[[UIView alloc] init] autorelease];
- [cell setBackgroundView:tempView];
- [cell setBackgroundColor:[UIColor clearColor]];
5.设置cell的背景或者背景色通过backgroundView,backgroundColor
- [cell setBackgroundView:XXXView];
- [cell setBackgroundColor:[UIColor XXX]];
总结:UITableViewCell中有一对相对的属性来定义cell平常和选中时的状态,即selectedBackgroundView和backgroundView。你可以对这两个view自定义实现自己想要的效果。
欢迎喜欢交流和热心的iphone开发朋友加入qq群参与讨论:186739796,验证码:csdn。
2662

被折叠的 条评论
为什么被折叠?



