tableViewCell右滑文字改为图片显示
2016-11-29 本文已影响69人
搬运工开发者
Untitled.gif
自定义tableViewCell,并在.m 文件执行以下代码
- (void)layoutSubviews{
[super layoutSubviews];
for (UIView *subView in self.subviews) {
if([subView isKindOfClass:NSClassFromString(@"UITableViewCellDeleteConfirmationView")]) {
// 拿到subView之后再获取子控件
UIView *deleteConfirmationView = subView.subviews[0];
for (UIView *deleteView in deleteConfirmationView.subviews) {
UIImageView *deleteImage = [[UIImageView alloc] init];
deleteImage.contentMode = UIViewContentModeScaleAspectFit;
//Delete为图片
deleteImage.image = [UIImage imageNamed:@"Delete"];
deleteImage.frame = CGRectMake(0, 0, deleteView.frame.size.width, deleteView.frame.size.height);
[deleteView addSubview:deleteImage];
}
}
}
}