在UITableViewCell中滑动以删除为白色背景,需要清除 [英] Swipe to Delete in UITableViewCell has white background, need clear

查看:74
本文介绍了在UITableViewCell中滑动以删除为白色背景,需要清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更改在滑动UITableViewCell行时出现的视图的背景颜色,即删除"按钮后面的背景颜色.

I am trying to change the background color of the view that appears when you swipe a UITableViewCell row, the background color behind the 'Delete' button.

我尝试更改cell.editingAccessoryView,但没有执行任何操作.

I tried changing the cell.editingAccessoryView but that didn't do anything.

    UIView* myBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
    myBackgroundView.backgroundColor = [UIColor clearColor];
    cell.editingAccessoryView = myBackgroundView;

有什么想法吗?

推荐答案

我正在回答这个问题,因为花了我一段时间才找到答案,这是搜索中出现的第一个条目.通过使用willDisplayCell方法,您可以访问单元格的背景色.请注意,[UIColor clearColor];将返回白色,因此请相应地调整代码.

I'm answering this because it took me a while to find an answer and this is the first entry that comes up in a search. By using the willDisplayCell method you can access the cells background color. Note that [UIColor clearColor]; will return white in so adjust your code accordingly.

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    cell.backgroundColor = [UIColor blackColor];

}

这篇关于在UITableViewCell中滑动以删除为白色背景,需要清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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