目前我正在尝试自定义 UITableViewCell 中的删除按钮。
现在我得到了类似的东西:
现在,我只需要更改此按钮的颜色即可,我不想更改其行为,也不想使其完全自定义。我确信这是可能的,无需创建您自己的控件来删除 UITableView 中的行。
这是我的代码:
- (void)layoutSubviews
{
[super layoutSubviews];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
deleteButtonView.backgroundColor = [UIColor greenColor];
}
}
}
我该怎么做?
提前致谢!
最佳答案
UITableViewCellDeleteConfirmationControl 不是公共(public)类,您无法轻易更改其外观。
为此,我相信您必须遍历单元格的 subview 并更改其属性:
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl") {
// Set the background using an image.
}
}
当然,你应该小心做这种事情,因为它相当脆弱。我建议您自己动手。
我建议 submitting a bug report向 Apple 请求能够更轻松地对其进行编辑。
关于objective-c - 更改 UITableViewCell 中 UITableViewCellDeleteConfirmationControl(删除按钮)的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12130856/