aarie
aarie

Reputation: 31

UISegmentedControl Color Issue - Color Shows Fine on Simulator, Not on Device

FIXED!

You won't believe it... It was a Winterboard theme messing with it! The bugger! Disabled theme and voila, works perfectly. The theme in question was "Ayecorn" for anyone interested. Not cool! Hope this helps anyone else who encounters the same issue.

Sorry folks, and thanks for all the input! Great community here.

Original Question:

So a simple test iPhone app in Xcode 4.5:

Create a view with a UISegmentedControl via Storyboard, and set the color via attributes inspector.

Run it on simulator, color shows fine:

enter image description here

Run it on device, color is see-thru/clear.

enter image description here

(Yes in this example above I have colored individual segments, but I even created a new project, added segment control to the view (Bar Type) and it came out see thru!? What gives?

Anyone experienced this before and have and advice on how to correct this?

Thanks

Upvotes: 3

Views: 366

Answers (4)

aarie
aarie

Reputation: 31

You won't believe it... It was a Winterboard theme messing with it! The bugger! Disabled theme and voila, works perfectly. The theme in question was "Ayecorn" for anyone interested. Not cool!

Thanks for all the input guys! Great community here!

Upvotes: 0

James Holderness
James Holderness

Reputation: 23001

It's possible you have the Opaque option unchecked in the Drawing section of the View Attributes.

I vaguely recall having an issue similar to this where the behaviour on the emulator was different from that of the device and it was related to the Opaque setting.

Upvotes: 0

Prince Kumar Sharma
Prince Kumar Sharma

Reputation: 12641

Try pasting below code

- (void)viewDidLoad
{
    UISegmentedControl *segmentControl=[[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"1",@"2",nil] ];
    [segmentControl setSegmentedControlStyle:UISegmentedControlStyleBar];
    [segmentControl setFrame:CGRectMake(20, 20, 200, 30)];

    [self.view addSubview:segmentControl];

    [segmentControl addTarget:self action:@selector(changeSegment:) forControlEvents:UIControlEventValueChanged];

    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)changeSegment:(UISegmentedControl*)sender
{
    for (int i=0; i<[sender.subviews count]; i++)
    {
        UIColor *tintcolor;
        if ([[sender.subviews objectAtIndex:i]isSelected] )
        {
            tintcolor=[UIColor redColor];
            [[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
        }

        if (![[sender.subviews objectAtIndex:i]isSelected]){
            tintcolor=[UIColor grayColor];
            [[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
        }
    }
}

Upvotes: 1

Engnyl
Engnyl

Reputation: 1380

Your simulator might have cached the older images you used before. Clean your simulator and entire project to make sure the images are properly loaded on your simulator.

Upvotes: 1

Related Questions