UITableViewCell, Delete Button Frame?

前端 未结 3 1585
南旧
南旧 2020-12-17 00:52

Is there a way to alter the frame of the \"swipe\" [DELETE] button used on UITableViewCells? Currently its centred vertically within the cell, but

相关标签:
3条回答
  • 2020-12-17 01:22

    If you are looking for a strongly true way to solve this problem then you should to subclass of UITableViewCell and override the all state handling methods for correct drawing your own delete button (do not call super in those methods). But there is another easy way:

    @implementation CustomCell
    - (void)layoutSubviews {
           [super layoutSubviews];
           if (self.showingDeleteConfirmation) {
                 if ([self.subviews count] < 4) return;
                 UIView *delBtn = [self.subviews objectAtIndex:3];
                 delBtn.frame = CGRectOffset(delBtn.frame, 0, 10);
           }
    }
    @end
    
    0 讨论(0)
  • 2020-12-17 01:25

    Try changing the frame for Accessory View

    0 讨论(0)
  • 2020-12-17 01:29

    Instead of didTransitionToState:,

    How about using the -(void)willTransitionToState: and setting the frame of the editingAccessoryView?

    - (void)willTransitionToState:(UITableViewCellStateMask)state
    {
        if (state == UITableViewCellEditingStyleDelete) 
        {
    
            NSInteger num = 10;
    
            UIView.frame = CGRectMake(UIView.frame.origin.x,UIView.frame.origin.y - num,
            UIView.size.width,UIView.size.height);
        }
    }
    
    0 讨论(0)
提交回复
热议问题