Reputation: 14864
I have a UITableView with a certain background, say red. The view holding the UITableView has a, say, blue background. I want to give the UITableView some left, right, top, and bottom margin so that the blue of the parent view shows on all sides. How do I do that? I tried playing around with tableView.contentInset
but it's not working.
e.g.
tableView.contentInset = UIEdgeInsetsMake(0, -15, 0, -15);
Upvotes: 0
Views: 964
Reputation: 7466
UPDATED TO FIT PROGRAMATIC APPROACH:
Instead of using UItableViewController which has its tableview "stitched to the border",
1) use a normal UIViewController
subclass
2)make it implement UITableViewDelegate
& UITableViewDatasource
protocols
3) declare a tableView property
4) override viewDidLoad in your viewcontroller and in there, initialize the table view property with a frame smaller than the main view and origin so that there are margins for example {20,20, 280, 440}.
Upvotes: 1