我最近添加了一個分段控件到我的tableview的節標題,一切正常,但它調整了錯誤的方式..我想申請一些保證金,但如果我設置框架它沒有任何影響的大小分段控制?我做錯了什麼?這裏是我的代碼:如何將UISegmentedControl添加到帶有頁邊空白的UITableView的Section頁眉?
- (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;
}