I’m putting a UISegmentedControl and UIBarButtonItem inside of a UIToolBar with the following code:
UISegmentedControl *prevNext = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Previous", @"Next", nil]];
prevNext.segmentedControlStyle = UISegmentedControlStyleBar;
[prevNext addTarget:self action:@selector(prevNextPressed) forControlEvents:UIControlEventValueChanged];
prevNext.tintColor = [UIColor blackColor];
UIBarButtonItem *prevNextButton = [[UIBarButtonItem alloc] initWithCustomView:prevNext];
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(closeKeyboard)];
done.tintColor = [UIColor blackColor];
With this code the UISegmentedControl and UIBarButtonItem are static looking controls that don’t change their appearance when touched.
If I comment out the lines that set the tintColor property, then they don’t look as good, but at least they visually respond to touch.
Why does this happen, and any ideas on how I can fix it?
The visual effect when a bar button or segmented control is touched always darkens it. Since your starting tint color is black, the button can’t get any darker, so its appearance doesn’t change. Try another color, like a dark gray—
[UIColor colorWithWhite:0.2 alpha:1], maybe.