Indenting a custom table view cell

旧时模样 提交于 2019-12-08 07:31:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!