Strange behavior with UISegmentedControl and UIAppearance

I set the appearance of the segmented control through these statements in the application delegate.

    [[UISegmentedControl appearance] setBackgroundImage:[[UIImage imageNamed:@"segmentation_normal.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0 , 0, 0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UISegmentedControl appearance] setBackgroundImage:[[UIImage imageNamed:@"segmentation_selected.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0 , 0, 0)] 
        forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

    [[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"segmentation_divider_NormalNormal.png"]   forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"segmentation_divider_NormalSelected.png"] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
    [[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"segmentation_divider_SelectedNormal.png"] forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

The result is perfect. Backgrounds and separators are set correctly when I select any of the segments (the order segment is selected by default when the application starts first). When I select the Release segment, as you can see below, everything looks fine.

enter image description here

The problem is when I exit the view and then back to the view (I save the selected index and set it to viewDidLoad to re-select the segment), the delimiter is set incorrectly for an unknown reason.

enter image description here

A-Z, Release, . , Release, A-Z. , .

: 2 ( 3 ), 2 px.

, 10 , , .

+5
1

UISegmentedControl, . , , . , - :

[self performSelector:@selector(setPreferences) withObject:nil afterDelay:0.0];

setPreferences .

+7

All Articles