//顶部显示bar
topBar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
//iOS 5
UIImage *toolBarIMG = [UIImage imageNamed: @"header_bg"];
if ([topBar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) {
[topBar setBackgroundImage:toolBarIMG forToolbarPosition:0 barMetrics:0];
}
} else {
//iOS 4
[topBar insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"header_bg"]] atIndex:0];
}
[self.view addSubview:topBar];