-2

I want to do a large tableView header like in Health app in iOS 11. I added a screenshot to show this element in red text. How to do large a tableView header?

  • The large "header" which will becomes title in Nav Bar when scrolled is new features in iOS 11. If you want that features (and only available on iOS 11), that's call `Prefers Large Titles`. If you want to use that style in iOS 10 (and older, then you will have to write a lot of codes for that. – John Pang Sep 02 '18 at 09:58

4 Answers4

4

If I understand your question correctly (and unfortunately the screenshot is gone), you can do that using the prefersLargeTitles property. This works on iOS 11 and higher only.

For instance:

if (@available(iOS 11.0, *)) {
    self.navigationController.navigationBar.prefersLargeTitles = YES;
    self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;

} else {
    // Fallback on earlier versions
}

You can call this code in viewDidLoad or viewWillAppear of your UITableViewController.

koen
  • 5,383
  • 7
  • 50
  • 89
  • Alternatively, you can do this in Storyboard. First select your `UINavigationController` in sb, select `Navigation Bar` from left hand side, then on right hand side, check the box `Prefers Large Titles`. Also set the title on your UIViewController / UITableViewController. I tested with iOS 10 simulator: this doesn't crash iOS 10 (and of course no effect on iOS 10). – John Pang Sep 02 '18 at 10:01
0

No recorded Data is table view header. you can customize the tableview header with viewForHeaderInSection method of tableview. Your question is already answered in this link. Changing Font Size For UITableView Section Headers

asd
  • 66
  • 7
0

Just set the frame property of the tableHeaderView.

0
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

UILabel *TESTLabel = [[UILabel alloc] init];
TESTLabel .frame = CGRectMake(20, 8, 320, 40);
TESTLabel .font = [UIFont boldSystemFontOfSize:18];
TESTLabel .text = [self tableView:tableView titleForHeaderInSection:section];

UIView *headerView = [[UIView alloc] init];
[headerView addSubview: TESTLabel];

return headerView;
}

TRY THIS

Dishant Rajput
  • 1,329
  • 1
  • 10
  • 20