Pranit Kothari
Pranit Kothari

Reputation: 9841

How to set top margin of table view in iOS?

I am new to iOS development, and my code is running fine in iOS6, but in iOS7 it has some UI issues.

Please see following image. I wanted to add margin to table view, but as stated it was perfect in iOS 6. Question may seem very basic, but I am trying to find any property using which I can add margin.

Secondly, if I need to do it programmatically, please suggest where I should write the code.

I tried to search on google, but may be I am not able to search with correct terms. I am C++ developer and new to Objective C and Mac.

enter image description here

Upvotes: 6

Views: 7483

Answers (2)

Jasarien
Jasarien

Reputation: 58448

On your table view controller, set the edgesForExtendedLayout property to UIRectEdgeTop.

You can use this property to extend views beneath top bars, (status and navigation bars) and bottom bars (toolbars and tab bars).

The value is a bit mask with possible values of:

UIRectEdgeNone,
UIRectEdgeTop,
UIRectEdgeLeft,
UIRectEdgeRight,
UIRectEdgeBottom,
UIRectEdgeAll

Upvotes: 0

ClemensL
ClemensL

Reputation: 414

You can do this by setting your tableViews contentInset or contentOffset depending on your needs.

[self.tableView setContentInset:UIEdgeInsetsMake(top, left, bottom, right)];

Upvotes: 7

Related Questions