您的位置:首页 > 产品设计 > UI/UE

iOS UITableViewCell 改变系统选中按钮(UITableViewCellEditControl)的默认图片和位置

2017-06-02 10:34 681 查看
系统效果:



1.只改变蓝色底色,可以//    cell.tintColor = [UIColor redColor];

2.改变图片和位置,

- (void)setEditing:(BOOL)editing animated:(BOOL)animated{
[super setEditing:editing animated:animated];
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
for (UIView *v in control.subviews){
if ([v isKindOfClass: [UIImageView class]]) {
UIImageView *img=(UIImageView *)v;
// img.frame = CGRectMake(img.frame.origin.x, CountHeight(20), img.frame.size.width, img.frame.size.height);
img.center = CGPointMake(img.center.x, img.frame.size.height+5);
if (!self.selected) {
img.image=[UIImage imageNamed:@"weixuanzhongimg.png"];
}
}
}
}
}
}

-(void)layoutSubviews{
NSLog(@"%@",self.subviews);
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
for (UIView *v in control.subviews){
if ([v isKindOfClass: [UIImageView class]]) {
UIImageView *img=(UIImageView *)v;
img.center = CGPointMake(img.center.x, img.frame.size.height+5);

// img.frame = CGRectMake(img.frame.origin.x, CountHeight(20), img.frame.size.width, img.frame.size.height);
if (self.selected) {
img.image=[UIImage imageNamed:@"xuanzhongimg.png"];
}else{
img.image=[UIImage imageNamed:@"weixuzhongimg.png"];
}
}
}
}
}
[super layoutSubviews];
}

效果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: