请问如何将UITableViewCell中的uitableviewcellaccessorydisclosureindicator的背景设置为透明?
目前我遇到了这个问题:
请问如何将UITableViewCell中的uitableviewcellaccessorydisclosureindicator的背景设置为透明?
目前我遇到了这个问题:
刚刚找到了答案。原来只需要3行代码,还要定义一个透明背景的披露指示符.png图片:
UITableViewCell *bgView = [[UITableViewCell alloc] initWithFrame:CGRectZero];
bgView.backgroundColor=indexPath.row % 2? [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1]: [UIColor whiteColor];
bgView.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"disclosure.png"]];
cell.backgroundView=bgView;
return cell;
UITableView
的委托中,重写委托方法 tableView:willDisplayCell:forRowAtIndexPath:
。在这里,将单元格的 backgroundColor
属性设置为任何颜色,附属视图的背景颜色应匹配。cell.contentView.backgroundColor=[UIColor grayColor];//or any color
cell.backgroundColor=[UIColor grayColor];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.accessoryView.backgroundColor=[UIColor clearColor];