简体   繁体   English

如何为iPhone ios 4.3设置UISegmentedControl的字体颜色

[英]How to set font color of UISegmentedControl for iPhone ios 4.3

How to set font color of UISegmentedControl for iPhone ios 4.3? 如何为iPhone ios 4.3设置UISegmentedControl的字体颜色?

For ios 5.0 i use 对于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;    

It might not be such a bad idea to use a custom project, especially because OS 4.x doesn't have the deep UIKit customization possible in 5.x. 使用自定义项目可能不是一个坏主意,特别是因为OS 4.x在5.x中没有进行深度UIKit自定义。 Here's an excellent one in Github which actually solves both of your requirements for setting both the size and color of the UIControl: Here 这里有一个很好的一个在Github上实际上解决您的两个设置了体积和UIControl的颜色要求: 这里

EDIT: it looks like the project automatically chooses the font color to match the selected color. 编辑:看起来项目会自动选择字体颜色以匹配所选颜色。 At least it's a start. 至少这是一个开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM