Changing the location of the minus sign in UITable

2019-09-07 05:48发布

问题:

I want to change the location of the minus image from the left side of the cell to the middle of it. Tried reading here: http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/ManageInsertDeleteRow/ManageInsertDeleteRow.html but couldn't find an easy way for doing that.

Thanks

回答1:

In your custom cell layoutSubviews method use:

if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
        CGRect newFrame = subview.frame;
        //Use your desired x value
        newFrame.origin.x = 280;
        subview.frame = newFrame;    
}

as shown here https://stackoverflow.com/a/8512461/1747635.