2012-12-17 3 views
0

안녕하세요, UISegmentedControls를 보여줘야하지만 UISegment의 텍스트가 왼쪽으로 세그먼트 밖으로 나옵니다 .UISegmented Control의 중심에있는 텍스트를 얼라인먼트하는 방법은 무엇입니까?센터에서 UISegment 텍스트를 맞추는 방법

optionControl = [[UISegmentedControl alloc]initWithItems:optionNameArr];         
[optionControl setFrame:CGRectMake(ReportingPanelScrollView.frame.size.width/2.8+80, y_Val +x_Dis, 100, 30)]; 
UIFont *font = [UIFont systemFontOfSize:12.0f]; 
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font,UITextAttributeFont,[UIColor darkTextColor],UITextAttributeTextColor,nil]; 
[optionControl setTitleTextAttributes:attributes forState:UIControlStateNormal]; 
optionControl.segmentedControlStyle = UISegmentedControlStyleBordered; 

optionControl.tag = sectionHeader*2000+itemHeader+200; 
NSString *tagStr = [NSString stringWithFormat:@"%d",optionControl.tag]; 
[optionItemControlDict setObject:optionSelectedTextArr forKey:tagStr]; 
[optionControl addTarget:self action:@selector(OptionControlSelected:) forControlEvents:UIControlEventValueChanged]; 

[ReportingPanelScrollView addSubview:optionControl]; 
[optionControl release]; 

답변

0

이 시도 :

optionControl.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter; 
관련 문제