0
我添加了分段控件到可用視圖的標題。這工作正常。但由於某些原因,我無法使分段按鈕(或至少只是第一個按鈕)具有紅色背景色。它只是加載默認的銀色。更改分段的控制段背景不起作用
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView* NEWview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
NEWview.backgroundColor = [UIColor colorWithRed:78.0/255.0f green:88.0/255.0f blue:74.0/255.0f alpha:1.0];
NSArray *itemArray = [NSArray arrayWithObjects: @"Organisations", @"Events", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = CGRectMake(15, 5, 290, 30);
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1;
UIColor *newSelectedTintColor = [UIColor redColor];
[[[segmentedControl subviews] objectAtIndex:0] setTintColor:newSelectedTintColor];
[NEWview addSubview:segmentedControl];
return NEWview;
}
任何想法?在此先感謝您的幫助..
這只是文字,我需要將選項卡的背景更改爲紅色 – user987723
檢查編輯好的anser –