0
我用於導航欄背景的圖像是640x88。導航欄的代碼如下。它適用於iOS4.3模擬器,但背景圖像在iOS 5模擬器上顯示爲正常的兩倍。如何在iOS 5.0上調整背景圖像?iOS5上的自定義導航欄背景
@implementation UINavigationBar (CustomBackground)
- (UIImage *)barBackground {
[self setTintColor:[UIColor colorWithRed:0.5f
green: 0.25f
blue:0.09f
alpha:0.6]];
UIImage *image;
image=[UIImage imageNamed:@"audioNav.png"];
return image;
}
- (void)didMoveToSuperview {
//iOS5 only
if ([self respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
[self setBackgroundImage:[self barBackground] forBarMetrics:UIBarMetricsDefault];
}
}
- (void)drawRect:(CGRect)rect {
[[self barBackground] drawInRect:rect];
}
謝謝!非常感謝!它現在有效! – user503698 2012-03-12 20:34:37