简体   繁体   English

UITableView编辑模式删除按钮右侧填充

[英]UITableView edit mode delete button padding-right

I want to give some space between UITableView edit mode delete button and cell left side (See screenshot below). 我想在UITableView 编辑模式删除按钮和单元格左侧之间一些空间(请参见下面的屏幕截图)。
Any idea? 任何想法?


(source: mixdesign.kz ) (来源: mixdesign.kz

Setting indentationLevel/indentationWidth did not work for me. 设置indentationLevel / indentationWidth对我不起作用。

What worked for me was subclassing UITableViewCell and customized -layoutSubviews : 对我-layoutSubviews是子类化UITableViewCell和自定义的-layoutSubviews

#define LEFT_EDITING_MARGIN 42

- (void)layoutSubviews
{
    [super layoutSubviews];

    if (self.editing && self.contentView.frame.origin.x != 0) {
        CGRect frame = self.contentView.frame;
        CGFloat diff = LEFT_EDITING_MARGIN - frame.origin.x;
        frame.origin.x = LEFT_EDITING_MARGIN;
        frame.size.width -= diff;
        self.contentView.frame = frame;
    }
}

You could implements 你可以实现

- (void)willTransitionToState:(UITableViewCellStateMask)state

in your UITableViewCell subclass to slightly move your subviews in order to have a larger padding. 在您的UITableViewCell子类中稍微移动您的子视图以具有更大的填充。

@property(nonatomic) NSInteger indentationLevel is a property define din UITableViewCell documentation . @property(nonatomic)NSInteger indentationLevel是UITableViewCell文档中定义的属性。 Using this you can set the indentation level of a tableview Cell. 使用此功能,您可以设置表格视图单元格的缩进级别。 Set this property from your - (void)willTransitionToState:(UITableViewCellStateMask)state - (void)willTransitionToState:(UITableViewCellStateMask)state设置此属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM