How to get a padding inside TableView?

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.


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..

  1. resize the individual cells if possible (might collide with the TableView's layout process)
  2. apply a content offset to the TableView as above


For width, you are going to have to mess with each cells frame. as for top and bottom inset, use setContentInset:

Need Your Help

How to check if a program is using .NET?

.net process executable

Can we check if a running application or a program uses .Net framework to execute itself?

Does the JVM cache assembly code?

java jvm jvm-hotspot

Assuming that a system is running the standard JVM (HotSpot) with JIT enabled, is jitted assembly code in any way cached between runs of the same program? I can find no information demonstrating this

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.