2011-11-27 74 views
0

如何设置用于iPhone ios 4.3的UISegmentedControl的字体颜色?如何设置UISegmentedControl for iPhone的字体颜色ios 4.3

为iOS 5.0,我使用

UISegmentedControl *button = [[[UISegmentedControl alloc] 
initWithItems:[NSArray >arrayWithObjects:itemTitle, nil]] autorelease]; 

NSDictionary *attributes = [NSDictionary dictionaryWithObject:fontColor forKey:UITextAttributeTextColor]; 
[button setTitleTextAttributes:attributes forState:UIControlStateNormal]; 


button.momentary = YES; 
button.segmentedControlStyle = UISegmentedControlStyleBar; 
button.tintColor = tintColor;  

回答

1

它可能不是使用自定义的项目,特别是因为OS 4.x版不具备深厚的UIKit定制可能在5.x中一个坏主意这是Github的一个很好的例子,它实际上解决了您设置UIControl的大小和颜色的两个要求:Here

编辑:它看起来像项目自动选择字体颜色以匹配选定的颜色。至少这是一个开始。