Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove padding of content view in UITableViewCell though storyboard

How to remove the default padding of content view in UITableViewCell?

I put two label in the UITableViewCell's content view, The content view has a gray background color.

when I set top margin space between title and the content view to 0 (via constraint), the title is not align to the top!!! The same is leading and trailing space.

padding of content view in UITableCell

Here is my view struct:

enter image description here

I googled a lot, the answer in this post works by overriding the layoutSubviews of UITableViewCell and setting frame of title manually.

But can I do it in story board? or it there a attribute or something that controls the padding of the content view????

like image 246
Guangming Mao Avatar asked Dec 19 '14 07:12

Guangming Mao


1 Answers

There is a checkbox labeled "Constrain to margins" in the popup where you specify constraints. I suspect you left it checked. Margins default to 8 points, which may explain what you are seeing.

Here is a better answer with screenshots: https://stackoverflow.com/a/26755511/4122965

like image 188
Sterling Christensen Avatar answered Nov 04 '22 01:11

Sterling Christensen