Customize the delete button in UITableView

后端 未结 3 1319
清歌不尽
清歌不尽 2020-12-05 12:41

I have the functionality for \"Swipe to delete\" the TableViewCell. I want to customize the Delete button.

3条回答
  •  醉酒成梦
    2020-12-05 12:53

    This method will be called when user performs the swipe action

    Just Place this in your CustomCell

    - (void)willTransitionToState:(UITableViewCellStateMask)state
        {
            [super willTransitionToState:state];
            if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
            {
                for (UIView *subview in self.subviews)
                {
                    if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"])
                    {
                        UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
                        [deleteBtn setImage:[UIImage imageNamed:@"arrow_left_s11.png"]];
                        [[subview.subviews objectAtIndex:0] addSubview:deleteBtn];
                    }
                }
            }
        }
    

    You should not try that, you are not supposed to alter Apple's default views .

提交回复
热议问题