【发布时间】:2012-02-20 05:36:24
【问题描述】:
我尝试将 UISegmentedControl 的字体颜色从白色更改为黑色(适用于 iOS 4.*)
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 的文本颜色?
【问题讨论】:
标签: iphone objective-c cocoa-touch uisegmentedcontrol