title: Design UITableView's section header in Interface Builder
body: <p>I have a <code>xib</code> file with a <code>UITableView</code> for which I want to add a custom section header view using the delegate method <code>tableView:viewForHeaderInSection:</code>. Is there any possibility to design it in <code>Interface Builder</code> and then change some of it's subview's properties programmatically?</p>
  
  <p>My <code>UITableView</code> has more section headers so creating one <code>UIView</code> in <code>Interface Builder</code> and returning it doesn't work, because I'd have to duplicate it, but there isn't any good method of doing it. Archiving and unarchiving it doesn't work for <code>UIImage</code>s so <code>UIImageView</code>s would show up blank.</p>
  
  <p>Also, I don't want to create them programmatically because they are too complex and the resulting code would be hard to read and maintain.</p>
  
  <p><strong>Edit 1</strong>: Here is my <code>tableView:viewForHeaderInSection:</code> method:</p>
  
  <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  
      if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
          return nil;
      }
  
      CGSize headerSize = CGSizeMake(self.view.frame.size.width, 100);
  
      /* wrapper */
  
      UIView *wrapperView = [UIView viewWithSize:headerSize];
  
      wrapperView.backgroundColor = [UIColor colorWithHexString:@"2670ce"];
  
      /* title */
  
      CGPoint titleMargin = CGPointMake(15, 8);
  
      UILabel *titleLabel = [UILabel labelWithText:self.categoriesNames[section] andFrame:CGEasyRectMake(titleMargin, CGSizeMake(headerSize.width - titleMargin.x * 2, 20))];
  
      titleLabel.textColor = [UIColor whiteColor];
      titleLabel.font = [UIFont fontWithStyle:FontStyleRegular andSize:14];
  
      [wrapperView addSubview:titleLabel];
  
      /* body wrapper */
  
      CGPoint bodyWrapperMargin = CGPointMake(10, 8);
  
      CGPoint bodyWrapperViewOrigin = CGPointMake(bodyWrapperMargin.x, CGRectGetMaxY(titleLabel.frame) + bodyWrapperMargin.y);
      CGSize bodyWrapperViewSize = CGSizeMake(headerSize.width - bodyWrapperMargin.x * 2, headerSize.height - bodyWrapperViewOrigin.y - bodyWrapperMargin.y);
  
      UIView *bodyWrapperView = [UIView viewWithFrame:CGEasyRectMake(bodyWrapperViewOrigin, bodyWrapperViewSize)];
  
      [wrapperView addSubview:bodyWrapperView];
  
      /* image */
  
      NSInteger imageSize = 56;
      NSString *imageName = [self getCategoryResourceItem:section + 1][@"image"];
  
      UIImageView *imageView = [UIImageView imageViewWithImage:[UIImage imageNamed:imageName] andFrame:CGEasyRectMake(CGPointZero, CGEqualSizeMake(imageSize))];
  
      imageView.layer.masksToBounds = YES;
      imageView.layer.cornerRadius = imageSize / 2;
  
      [bodyWrapperView addSubview:imageView];
  
      /* labels */
  
      NSInteger labelsWidth = 60;
  
      UILabel *firstLabel = [UILabel labelWithText:@"first" andFrame:CGRectMake(imageSize + bodyWrapperMargin.x, 0, labelsWidth, 16)];
  
      [bodyWrapperView addSubview:firstLabel];
  
      UILabel *secondLabel = [UILabel labelWithText:@"second" andFrame:CGRectMake(imageSize + bodyWrapperMargin.x, 20, labelsWidth, 16)];
  
      [bodyWrapperView addSubview:secondLabel];
  
      UILabel *thirdLabel = [UILabel labelWithText:@"third" andFrame:CGRectMake(imageSize + bodyWrapperMargin.x, 40, labelsWidth, 16)];
  
      [bodyWrapperView addSubview:thirdLabel];
  
      [@[ firstLabel, secondLabel, thirdLabel ] forEachView:^(UIView *view) {
          UILabel *label = (UILabel *)view;
  
          label.textColor = [UIColor whiteColor];
          label.font = [UIFont fontWithStyle:FontStyleLight andSize:11];
      }];
  
      /* line */
  
      UIView *lineView = [UIView viewWithFrame:CGRectMake(imageSize + labelsWidth + bodyWrapperMargin.x * 2, bodyWrapperMargin.y, 1, bodyWrapperView.frame.size.height - bodyWrapperMargin.y * 2)];
  
      lineView.backgroundColor = [UIColor whiteColorWithAlpha:0.2];
  
      [bodyWrapperView addSubview:lineView];
  
      /* progress */
  
      CGPoint progressSliderOrigin = CGPointMake(imageSize + labelsWidth + bodyWrapperMargin.x * 3 + 1, bodyWrapperView.frame.size.height / 2 - 15);
      CGSize progressSliderSize = CGSizeMake(bodyWrapperViewSize.width - bodyWrapperMargin.x - progressSliderOrigin.x, 30);
  
      UISlider *progressSlider = [UISlider viewWithFrame:CGEasyRectMake(progressSliderOrigin, progressSliderSize)];
  
      progressSlider.value = [self getCategoryProgress];
  
      [bodyWrapperView addSubview:progressSlider];
  
      return wrapperView;
  }
  </code></pre>
  
  <p>and I would want it to look something like this:</p>
  
  <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  
      if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
          return nil;
      }
  
      SectionView *sectionView = ... // get the view that is already designed in the Interface Builder
  
      sectionView.headerText = self.categoriesNames[section];
      sectionView.headerImage = [self getCategoryResourceItem:section + 1][@"image"];
  
      sectionView.firstLabelText = @"first";
      sectionView.secondLabelText = @"second";
      sectionView.thirdLabelText = @"third";
  
      sectionView.progress = [self getCategoryProgress];
  
      return wrapperView;
  }
  </code></pre>
  
  <p><strong>Edit 2</strong>: I'm not using a <code>Storyboard</code>, just <code>.xib</code> files. Also, I don't have an <code>UITableViewController</code>, just an <code>UIViewController</code> in which I added an <code>UITableView</code>.</p>