UISegmented Control没有以正确的方式显示

时间:2015-09-07 20:40:31

标签: ios

我在iOS 8中初始化了一个UISegmentedControl,但出于某种原因,它显示为灰色背景,如旧样式(下面的代码)。

视图以编程方式加载,而不是从XIB加载。如果添加到XIB文件,它通常会显示。

看起来像这样:

enter image description here

但应该是这样的:

enter image description here

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Info", @"Medical", @"Team", @"Notes"]];
segmentedControl.frame = CGRectMake(contentLeftMargin, segmented_control_y, content_width, segmented_control_height);
[self.view addSubview:segmentedControl];

1 个答案:

答案 0 :(得分:0)

之前的开发人员在applicationDidFinishLoadingWithOptions中设置了应用范围内的默认值。

[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"segmented_bg_selected"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
相关问题