I have a TableView with a dark transparent
background which I'd like to have a padding
I tried to accomplish that using contentInsets
,
contentSize
and contentOffset
:
CGFloat padding = 10.0f;
CGSize size = self.tableView.bounds.size;
size.width -= (padding*2);
size.height -= (padding*2);
self.tableView.contentSize = size;
self.tableView.contentInset = UIEdgeInsetsMake(padding, padding, padding, padding);
self.tableView.contentOffset = CGPointMake(-padding, -padding);
That doesn't work. I get the padding, but neither are the cells resized nor respositioned.
I know, I could nest the TableView inside another View, but there should be another solution.
EDIT:
I actually had a misconception as to the meaning of 'contentSize'. It's not the viewport's size but the actual size of, you name it, the content. So I probably will have to..
- resize the individual cells if possible (might collide with the TableView's layout process)
- apply a content offset to the TableView as above