Specifying UISegmentedControlNoSegment to UISegmentedControl's selectedSegmentIndex has no Effect on iOS 13

前端 未结 3 946
后悔当初
后悔当初 2020-12-20 18:25

I am the maintainer of STAControls which subclasses various UIControls, one of which is UISegmentedControl. Within that project\'s sample app, I ha

3条回答
  •  没有蜡笔的小新
    2020-12-20 19:30

    The solutions given in the other answers are overblown. There is a much simpler workaround: just call setNeedsLayout on the segmented control.

    self.seg.selectedSegmentIndex = UISegmentedControl.noSegment
    self.seg.setNeedsLayout()
    

提交回复
热议问题