Customizing the colors of a UISegmentedControl

后端 未结 12 1856
萌比男神i
萌比男神i 2020-12-08 07:26

Does anybody know of a way to customize the appearance of the string based UISegmentedControl? I am trying to set the background color of the cell and the text color differe

12条回答
  •  我在风中等你
    2020-12-08 08:00

    All you have to do is:

    // Get an array of the subviews of a UISegmentedControl, for example myUISegmentedControl:
    
    NSArray *arri = [myUISegmentedControl subviews];
    
    // Change the tintColor of each subview within the array:
    
    [[arri objectAtIndex:0] setTintColor:[UIColor redColor]];
    
    [[arri objectAtIndex:1] setTintColor:[UIColor greenColor]];
    

提交回复
热议问题