IOS自定义UINavigationBar ios4与ios5通用
Here's a less-ugly solution that works for both iOS4 and 5:
@implementationUINavigationBar(CustomBackground)
-(UIImage*)barBackground
{
return[UIImage imageNamed:@"top-navigation-bar.png"];
}
-(void)didMoveToSuperview
{
//iOS5 only if([self respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
[self setBackgroundImage:[self barBackground] forBarMetrics:UIBarMetricsDefault];
}
}
//this doesn't work on iOS5 but is needed for iOS4 and earlier-(void)drawRect:(CGRect)rect
{
//draw image [[self barBackground] drawInRect:rect];
}
@end
浙公网安备 33010602011771号