I have a UIToolBar that should contain sliders for controlling volume and brightness. I use the MPVolumeView slider for volume and the regular UISlider for brightness. While the sliders themselves work fine, their vertical positions are incompatible:

How can I make them be at the same height?
My code is:
- (void) createToolbar{ toolBar = [[UIToolbar alloc] init]; toolBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 44); UISegmentedControl *modeSelector = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Play", @"Rec", nil]]; [modeSelector setSegmentedControlStyle:UISegmentedControlStyleBar]; [modeSelector addTarget:self action:@selector(changePlayMode) forControlEvents:UIControlEventValueChanged]; modeSelector.selectedSegmentIndex = 0; UIBarButtonItem *modeSelectorAsToolbarItem = [[UIBarButtonItem alloc] initWithCustomView:modeSelector]; brightnessSlider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 150, 30)]; brightnessSlider.minimumValue = 0; brightnessSlider.maximumValue = 1; brightnessSlider.value = [[UIScreen mainScreen] brightness]; brightnessSlider.continuous = YES; [brightnessSlider addTarget:self action:@selector(adjustBrightness:) forControlEvents:UIControlEventValueChanged]; UIBarButtonItem *brightSliderAsToolbarItem = [[UIBarButtonItem alloc] initWithCustomView:brightnessSlider]; MPVolumeView *volView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, 150, 30)]; volView.showsRouteButton = NO; UIBarButtonItem *volSliderAsToolbarItem = [[UIBarButtonItem alloc] initWithCustomView:volView]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *toc = [[UIBarButtonItem alloc] initWithTitle:@"Contents" style:UIBarButtonItemStyleBordered target:self action:@selector(goToToC)]; [toolBar setItems:[NSArray arrayWithObjects:modeSelectorAsToolbarItem, flexibleSpace, brightSliderAsToolbarItem, volSliderAsToolbarItem, flexibleSpace, toc, nil] animated:NO]; toolBar.autoresizingMask |= UIViewAutoresizingFlexibleWidth; [[self view] addSubview:toolBar]; }
(Changing the coordinates of CGRectMake does nothing.)
The comment in the question โ MPVolumeView Thumb custom image is not vertically centered with iOS 5.1 โ seemed to suggest using the โ Thumb Lock Pointer โ trick here , but the implementation of this code did not seem to do anything as far as I can tell, and I'm not sure I said Is it about the same problem.
source share