在UITableViewCell中更改UITableViewCellDeleteConfirmationControl(Delete Button)的颜色 [英] Changing the color of UITableViewCellDeleteConfirmationControl(Delete Button) in UITableViewCell
本文介绍了在UITableViewCell中更改UITableViewCellDeleteConfirmationControl(Delete Button)的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前,我正在尝试自定义UITableViewCell中的delte按钮.现在我有了类似的东西:
Currently I'm trying to customize delte button in UITableViewCell.
Now I've got something like that:
现在,我所需要做的就是更改此按钮的颜色,我不想更改其行为或使其完全自定义.我敢肯定,无需创建自己的用于删除UITableView中的行的控件就可以.
Now, all what I need is to change the color of this button, I don't want to change the behavior, or to make it absolutelly custom. I'm sure that it is possible, without creating your own controls for deleting rows in 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];
}
}
}
我该怎么做?
提前谢谢!
推荐答案
这是解决方案:
This is the solution:
- (void)layoutSubviews
{
[super layoutSubviews];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Background"]];
[deleteButtonView addSubview:image];
}
}
}
这篇关于在UITableViewCell中更改UITableViewCellDeleteConfirmationControl(Delete Button)的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文