views:

21

answers:

1

Come oon!

I am almost looking a day at this!

I want to set my tint color of my UISegmentedControl but it doesnt react...

NSArray *segControlItems = [NSArray arrayWithObjects:
        @"L", 
        @"H",
        @"A",
        nil];
 UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:segControlItems];

 segControl.frame = CGRectMake(0, 0, 90, 30);
 segControl.segmentedControlStyle = UISegmentedControlStyleBar;
 segControl.momentary = YES;
 segControl.tintColor = [UIColor greenColor];


 [segControl addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];

 UIBarButtonItem *segBarItem = [[UIBarButtonItem alloc] initWithCustomView:segControl];
 self.switchView.navigationItem.rightBarButtonItem = segBarItem;

 [segControl release];
 [segBarItem release];

Has apple made some property like "makeUISegmentedControlsDontSetAnyTintColor" ore soo? Please help...

A single button works: http://img257.imageshack.us/i/schermafbeelding2010102.png/

But with the segmented it's fucked up:http://img714.imageshack.us/i/schermafbeelding2010102.png/

+1  A: 

I've done it without problems using InterfaceBuilder. I had three segments, some with labels, some with labels + pictures, all working fine.

It must be your conversion into a BarButtonItem that doesn't work. You could try adding the segmented control as a subview of the nav bar instead of coaxing it into a button.

jv42
when i [self.switchView.navigationController.navigationBar addSubview:segControl]; i have still the same, cant set the tintColor
meersmans
Well, I don't have the code I used anymore, I know it was working out of the box, but my case was simpler. Sorry.
jv42
Np, i will keep looking. Worst case scenario i make some png-s of it.
meersmans
Man... hate this, is there an other way then the segmentcontrol to add more buttons at the navigationbar?
meersmans
Wooow.. have found it! This is really a bug in the ipad simultator/sdk i don't know: So if i want to add the Segmented Control in a NavigationController, do that first and change the tintcolor after u did that. Crazyyy.. cost me 2 days.
meersmans