moo*_*ots 8 iphone uitableview uicolor ios
我试图更改当您滑动UITableViewCell行时显示的视图的背景颜色,"删除"按钮后面的背景颜色.
我尝试更改cell.editingAccessoryView但是没有做任何事情.
UIView* myBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
myBackgroundView.backgroundColor = [UIColor clearColor];
cell.editingAccessoryView = myBackgroundView;
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在回答这个问题,因为我花了一些时间才找到答案,这是搜索中出现的第一个条目.通过使用该willDisplayCell方法,您可以访问单元格背景颜色.请注意,[UIColor clearColor];将返回白色,因此请相应地调整您的代码.
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor blackColor];
}
Run Code Online (Sandbox Code Playgroud)
你快到了.本UITableViewCell类有一个backgroundView属性,它是nil默认.只需UIView在问题中创建一个新的,然后将其分配给backgroundView单元格的属性.
cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
cell.backgroundView.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)