I use a "protective" code to set a custom image in the UINavigationBar - it works well on devices with ios5 or later.
After some answers, I edit the code with a combined answer (see below)
Is this the right and elegant way to do this?
if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {
UIImage *backgroundImage = [UIImage imageNamed:@"tableTitleView.png"];
[self.navigationController.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
}
else
{
NSString *barBgPath = [[NSBundle mainBundle] pathForResource:@"tableTitleView" ofType:@"png"];
[self.navigationController.navigationBar.layer setContents:(id)[UIImage imageWithContentsOfFile: barBgPath].CGImage];
}
chewy source
share