Why are my UISegmentControl segments highlighting in iOS 8 when I have set background images for all states?

前端 未结 2 1453
一生所求
一生所求 2021-01-02 07:47

In iOS 6/7, I have used UISegmentedControl with background images to create an effect like so:

\"Cu

2条回答
  •  一整个雨季
    2021-01-02 07:57

    The reason the segment turns grey on selecting an already selected segment is because the segmented control is missing the state for selected and highlighted at the same time.

    In your case calling:

    [self.segmentedControl setBackgroundImage:segmentedControlBackgroundSelectedImage forState:UIControlStateSelected | UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
    

    should fix that problem.

    when you change your selection, the cell you tapped turns gray until the transition completes

    I couldn't reproduce that one, but perhaps this will fix both issues.

提交回复
热议问题