가능한 중복은 :
UISegmentedControl selected segment color
UISegmentcontrol appearances causing issuesUISegmentcontrol 글꼴 및 선택한 세그먼트 색상을 변경하는 방법은 무엇입니까?
안녕 난 사용자 정의 글꼴을 기본 UISegmentControl 글꼴을 변경하고 어두운 대신에 다른 색으로 선택된 세그먼트의 색상을 변경하려면합니다 색깔.
덕분에이
편집이
에서
: 전화 솔루션
// 변경 글꼴 크기, 그림자를 제거, 선택한 텍스트 & 배경 색상이 정상 상태에서 다른
-(void)defineSegmentControlStyle
{
//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];
[infoSegment 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];
[infoSegment setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected];
}
http://stackoverflow.com/a/5932524/102937 –