美文网首页iOS学习
iOS---自定义cell的侧滑删除视图

iOS---自定义cell的侧滑删除视图

作者: 暮雨霜白 | 来源:发表于2016-11-17 18:05 被阅读442次

我是用的xib拉的自定义cell,在cell的.m文件中加入

-(void)layoutSubviews

{

[super layoutSubviews];

for (UIView *subView in self.subviews)

{

if([subView isKindOfClass:NSClassFromString(@"UITableViewCellDeleteConfirmationView")])

{

UIView *confirmView=(UIView *)[subView.subviews firstObject];

for(UIView *sub in confirmView.subviews)

{

//修改字的大小、颜色,这个方法可以修改文字样式

//

if ([sub isKindOfClass:NSClassFromString(@"UIButtonLabel")]) {

UILabel *deleteLabel=(UILabel *)sub;

deleteLabel.backgroundColor = [UIColor redColor];

deleteLabel.font=[UIFont boldSystemFontOfSize:20];

//改删除按钮的文字

deleteLabel.text=@"";

//

}

//添加图片

//

if ([sub  isKindOfClass:NSClassFromString(@"UIView")]) {

UIView *deleteView = sub;

UIView*fushi=deleteView.superview;

UIColor*tabcolor=COLOR_WITH_HEX(0xedf1f8);

fushi.backgroundColor=[UIColor redColor];


UIImageView *imageView = [[UIImageView alloc] init];

imageView.image = [UIImage imageNamed:@"中原地产CRM-14-消息工单_11.png"];

imageView.frame = CGRectMake((fushi.frame.size.width-ScreenWidth*93/1242)/2, (fushi.frame.size.height-ScreenHeight*93/2208)/2, ScreenWidth*93/1242, ScreenHeight*93/2208);

[fushi addSubview:imageView];

}

}

break;

}

}

}

要是字没除赶紧,那就在tableview添加的那个类实现协议方法

-(NSString*)tableView:(UITableView*)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath*)indexpath {

return @"          ";

}

希望能帮到你们!

相关文章

网友评论

    本文标题:iOS---自定义cell的侧滑删除视图

    本文链接:https://www.haomeiwen.com/subject/dwadpttx.html