So I have a UIToolbar
which has a custom height (which I set by overriding UIToolbar
's -sizeThatFits
. I want to position my UIBarButtonItems
higher in the tool bar. I do so by overriding -layoutSuviews
as such:
-(void)layoutSubviews
{
[super layoutSubviews];
for(UIBarButtonItem* item in self.items)
{
UIView *view;
@try {
view = [item valueForKey:@"view"];
}
@catch (NSException *exception) { NSLog(@"%@", exception.reason); }
view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-33);
}
}
}
This works fine for bar buttons made with -initWithBarButtonSystemItem:
, however it has no effect on bar buttons that I've made with -initWithCustomView:
or -initWithTitle:
.
Should I be using something different in [item valueForKey:@"view"]
, or is there a different way?