0
我正在使用下面的代碼來設置我的分段控件中的文本顏色。但是,它似乎並不奏效。我在這裏錯過了什麼嗎?無法更改segmentedControl中的字體顏色
// Set up segment control
NSArray *itemArray = [NSArray arrayWithObjects: @"Popular", @"Starred", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = CGRectMake(40, 200, 220, 20);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.selectedSegmentIndex = 0;
self.navigationItem.titleView = segmentedControl;
for (id segment in [segmentedControl subviews])
{
for (id label in [segment subviews])
{
if ([label isKindOfClass:[UILabel class]])
{
[label setTextAlignment:UITextAlignmentCenter];
[label setColor:[UIColor blackColor]];
}
}
}