views:

47

answers:

1

Hi,

In my Ipad app i started with a single UIBarButtonItem at the right: That + picture is just white.

self.switchView.navigationItem.rightBarButtonItem = nil;
 UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"add.png"] style:UIBarButtonItemStylePlain target:self action:@selector(insertKnoopPressed)];
    self.switchView.navigationItem.rightBarButtonItem = rightButton;
    [rightButton release];

With result: http://img257.imageshack.us/i/schermafbeelding2010102.png/

Now i have implemented the UISegmentedControl with the same + button, and also some additonal buttons:

NSArray *segControlItems = [NSArray arrayWithObjects:
        [UIImage imageNamed:@"location.png"], 
        [UIImage imageNamed:@"house.png"],
        [UIImage imageNamed:@"add.png"],
        nil];
 UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:segControlItems];


 segControl.frame = CGRectMake(0, 0, 135, 30);
 segControl.segmentedControlStyle = UISegmentedControlStyleBar;
 segControl.momentary = NO;

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

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

 [segControl release];
 [segBarItem release];

With result: hhttp://img714.imageshack.us/i/schermafbeelding2010102.png/

How can i have the same background color then the first button? Because this layout sucks.

Thanks

A: 

You change the tintColor of the segControl using the following line of code

[segControl setTintColor: [UIColor colorWithRed:0.40 green:0.40 blue:0.40 alpha:1.0]];

Hope this helps you.

Atulkumar V. Jain
No.. it is still the same...
meersmans
So the setTintColor wont work... but when i press the button I have actually the color i want: http://img139.imageshack.us/img139/313/schermafbeelding2010102.png. Why cant' i set the tintColor?
meersmans
the segmentedcontrol adjusts its color according to the navigationbar. So as the color of the navigationbar is blue hence the color of the segmentedcontrol is also blue. The color which you are seeing is the selected segment color.
Atulkumar V. Jain
But what if i don't want it to adjust its color? I just want to use the setTintColor property, but it doesnt react...
meersmans
its default behavior of navigationbar. If you want to change the color of ur segmentedcontrol remove it from the navigationbar and place it somewhere else...
Atulkumar V. Jain