【发布时间】:2016-07-07 22:23:59
【问题描述】:
如何更改表格视图单元格中删除按钮的图像?
我的意思是左侧的红色圆圈按钮:
【问题讨论】:
标签: ios uitableview cocoa-touch
如何更改表格视图单元格中删除按钮的图像?
我的意思是左侧的红色圆圈按钮:
【问题讨论】:
标签: ios uitableview cocoa-touch
在您的 UITableViewCell 子类中覆盖以下内容:
- (void)willTransitionToState:(UITableViewCellStateMask)state
{
[super willTransitionToState:state];
if(state == UITableViewCellStateShowingEditControlMask)
{
for (UIView *v in self.subviews) {
if ([NSStringFromClass([v class]) isEqualToString:@"UITableViewCellEditControl"]) {
UIImageView *customButton = [[UIImageView alloc]initWithFrame:v.bounds];
[customButton setImage:[UIImage imageNamed:@"delete.png"]];
[v addSubview:customButton];
[v bringSubviewToFront:customButton];
}
}
}
}
您可以使用子视图和状态来获得您喜欢的结果。
【讨论】:
UITableViewCell 子类和其中的此方法,并且您的表在 cellForRowAtIndexPath 中返回该类型的单元格
[tableView setEditing:YES]