Reputation: 3860
I am able to add view to the tableHeaderView using the below mentioned code:-
MyView *view=[[MyView alloc] init];
.....
tableView.tableHeaderView=view;
But, I am unable to add spacing between this view and headers of first section.
Upvotes: 0
Views: 1200
Reputation: 12421
You can encapsulate your main view like this:
MyView *view=[[MyView alloc] init];
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height + 5)]; //5 pixel gap
view.frame = CGRectMake(0, 5, view.frame.size.width, view.frame.size.height);
[headerView addSubview:view];
.....
tableView.tableHeaderView=headerView;
I've created a new headerView
, added the view to that view, and then set the tableHeaderView
appropriately.
Upvotes: 1
Reputation: 209
One solution that i can think is that you create a 'parent' view with height = (view.frame.height + )
Then add 'view' as a subview of 'parent' view and set 'parent' view as your table header.
Upvotes: 0