How to disable part of UISegmentedControl?

前端 未结 2 662
陌清茗
陌清茗 2021-02-03 17:37

Following is the code for UISegmentedControl

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObje         


        
相关标签:
2条回答
  • 2021-02-03 17:45

    Use setEnabled:forSegmentAtIndex: method to enable and disable the segments.

    [segmentedControl setEnabled:NO forSegmentAtIndex:0];
    

    if you want to disable the first segment.

    0 讨论(0)
  • 2021-02-03 17:50

    For those who can be interested in the swift command:

    Swift 2.3

    segmentedControl.setEnabled(false , forSegmentAtIndex: 0);
    

    Swift 3

    self.segmentedControl.setEnabled(false, forSegmentAt: 0);
    
    0 讨论(0)
提交回复
热议问题