所以我有一些代碼,我希望將分段控制器的選定顏色設置爲我所要求的顏色,將未選定的顏色段設置爲其他顏色,請參閱如下:UISegmentedControl將不允許我編輯選定的顏色
//normal segment
NSDictionary *normalAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Rok" size:20.0],UITextAttributeFont,
[UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
nil];//[NSDictionary dictionaryWithObject: [UIColor redColor]forKey:UITextAttributeTextColor];
[segmentedControl setTitleTextAttributes:normalAttributes forState:UIControlStateNormal];
NSDictionary *selectedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Rok" size:20.0],UITextAttributeFont,
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
nil] ;//[NSDictionary dictionaryWithObject: [UIColor redColor]forKey:UITextAttributeTextColor];
[segmentedControl setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected];
那麼我在做什麼錯了?直接改變選定片段的顏色非常困難真的很令人沮喪!我很想使用一排按鈕!
感謝任何人的幫助。
變化UISegmentedControl選擇段色 –