UISegmentedControl with custom color: separator line bug

后端 未结 2 466
栀梦
栀梦 2021-01-06 02:53

Its easy change the color of UISegmentedControl. I found various solution like this, this site and the best this solution. But none was what I want.

I tried create a

2条回答
  •  再見小時候
    2021-01-06 03:12

    I Think there is a lot easier solution. Just clean the pointers..

    for (int i=0; i<[self.segmentedControll.subviews count]; i++) 
    {
        [[self.segmentedControll.subviews objectAtIndex:i] setTintColor:nil];
        if (![[self.segmentedControll.subviews objectAtIndex:i]isSelected]) 
        {   
            UIColor *tintcolor=[UIColor blackColor];
            [[self.segmentedControll.subviews objectAtIndex:i] setTintColor:tintcolor];
        } 
        else 
        {
            UIColor *tintcolor=[UIColor blueColor];
            [[self.segmentedControll.subviews objectAtIndex:i] setTintColor:tintcolor];
        }
    }
    

提交回复
热议问题