2012-03-19 21 views
0

我在導航控制器中使用了UIToolBar。我曾嘗試使用下面的代碼在ios4中無法使用UIToolBar

if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { 
       NSLog(@"IOS 5555555"); 
     //iOS 5 
     if ([tools respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) { 
      [tools setBackgroundImage:[UIImage imageNamed:@"toolbar.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault]; 
     } 

    } else { 
     //iOS 4 
     NSLog(@"IOS 4444444"); 
     [tools insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"toolbar.png"]] autorelease] atIndex:0]; 
    } 

對於iOS5的正常工作設置UIToolbar的背景圖像,但是當我在iOS 4的運行我的應用程序將其設置工具欄的默認值。基本上我需要設置UIToolBar的背景圖像。

回答

1

我會建議iOs 4你子類UIToolbar和覆蓋drawRect方法