我尝试将 UISegmentedControl
(iOS4.*)的字体颜色从白色改为黑色
UISegmentedControl *button = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:itemTitle, nil]] autorelease];
button.momentary = YES;
button.segmentedControlStyle = UISegmentedControlStyleBar;
button.tintColor = [UIColor redColor];
for (id segment in [button subviews]) {
for (id label in [segment subviews]) {
if ([label isKindOfClass:[UILabel class]]) {
UILabel *titleLabel = (UILabel *) label;
[titleLabel setTextColor:[UIColor blackColor]];
}
}
}
UIBarButtonItem *barButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
但是文本颜色没有改变。我应该做什么来改变 UISegmentedControl
的文本颜色?