I’m customizing UINavigationBar and have to set a custom background image to the navigation buttons. This is done this way:
for (UIView *view in self.navigationController.navigationBar.subviews) {
if ([[[view class] description] isEqualToString:@"UINavigationButton"]) {
UINavigationButton *button = {(UINavigationButton *)view};
[button setBackgroundImage:[UIImage imageNamed:@"bar_button.png"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"bar_button_black.png"] forState:UIControlStateSelected];
[button setBackgroundImage:[UIImage imageNamed:@"bar_button_black.png"] forState:UIControlStateHighlighted];
}
}
Won’t this be rejected by Apple?
How can I make UIButton/UIView corners to be rounded?
Create your custom buttons as normal UIButtons, with your custom image. Then create UIBarButtonItems with your new UIButton as a custom view (you can see how to do this in the UIBarButtonItem class reference).
Then, set your view controller’s navigationItem to have your new UIBarButtonItems as the leftButtonItem, rightButtonItem and so on.