嗨,有一个应用程序必须显示 UISegmentedControls 但 UISegment 上的文本从向左的段中出来。如何在 UISegmented 控件的中心添加文本?
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];