问题
I have created a custom UITableViewCell using Storyboard. The cell contains 3 UILabel items. When the edit button is hit. The (-) sign slides in on the left but the cell does not indent and the (-) sign covers one of the UITextLabels.
I was wondering what is the best way to make all 3 UITextLabels indent when the edit button is hit. I have tried adding the 3 labels to a UIView (contentView) and adding it to the contentsView:
-(void)layoutSubviews {
[super layoutSubviews];
[self.contentView addSubview:self.theContent];
}
Although this renders the same result. Any suggestions?
回答1:
What is the frame of theContent? Have you tried modifying the frame (subtracting from the 'x' value the amount you want it to be indented)? You can even do this in a nice animation:
[UIView beginAnimations : @"cell edit" context:nil];
[UIView setAnimationDuration:1];
CGRect frame = theContent.frame;
frame.origin.x -= 40; // add or subtract here however much you want to indent and in which direction
theContent.frame = frame;
[UIView commitAnimations];
回答2:
You can set it in storyboard like this.
来源:https://stackoverflow.com/questions/11265963/indenting-a-custom-table-view-cell