Mas*_*son 4 objective-c uitableview ios
我为所有UITableViewCells设置了背景颜色.但是,当我单击我的UIBarButtonItem"编辑"时,删除和可拖动图标会扭曲背景颜色,使背后的白色背景.有没有办法解决?我可以在必要时显示代码,但这似乎是一个非常简单的问题.
小智 8
表格单元格的背景颜色通常设置如下:
cell.backgroundView.backgroundColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)
这很好用.但是,当创建UITableViewCell类的对象时,默认情况下它没有backgroundView,它是nil.开发人员需要在需要时创建backgroundView.因此,根据具体情况,您需要执行以下操作:
if (cell.backgroundView == nil) {
cell.backgroundView = [[[UIView alloc] init] autorelease];
}
cell.backgroundView.backgroundColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)
这是uitableviewcells
编辑模式中的默认行为.尝试再次为tableViewCells设置背景颜色
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
if(editing)
{
// set background color
}
else {
}
Run Code Online (Sandbox Code Playgroud)
如果需要,请尝试将背景颜色设置为您的属性,以便您可以在此处进行设置.
归档时间: |
|
查看次数: |
3727 次 |
最近记录: |