title: How to add a UISegmentedControl to Section header of UITableView with margin?
body: <p>I recently added a segmented control to a section header of my tableview, everything works fine, but it resizes the wrong way .. i want to apply some margin, but if i set the frame it does not have any effect on the size of the segmented control ? What i am doing wrong ? here is my code :</p>
  
  <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
      if(section == 0) {
          UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Segment 1", @"Segment 2",@"Segment 3"]];
          segmentedControl.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.95];
          [segmentedControl setFrame:CGRectMake(10, 0, self.view.bounds.size.width-10, self.view.bounds.size.height)];
  
          return segmentedControl;
      }
      return nil;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/iN9GP.png" alt="enter image description here"></p>