(转)navigationbar,tabbar,toolbar添加背景

 

 1 uinavigationbar:
2 UIImage *img = [UIImage imageNamed:@"background.png"];
3 navBar.layer.contents = (id)img.CGImage;
4
5 toolbar:
6 UIImageView *barBackgroudView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320,44)];
7 barBackgroudView.image = [UIImage imageNamed:@"tbackground.png"];
8 [self.navigationController.toolbar insertSubview:barBackgroudView atIndex:0];
9 [barBackgroudView release];
10
11 tabbar
12 CGRect frame = CGRectMake(0.0, 0.0, 320.0, 49.0);
13 UIView *v = [[UIView alloc] initWithFrame:frame];
14 UIImage *img = [UIImage imageNamed:@"tabbar.png"];
15 UIColor *c = [[UIColor alloc] initWithPatternImage:img];
16 v.backgroundColor = c;
17 [m_TabBar.tabBar insertSubview:v atIndex:0];
18 m_TabBar.tabBar.opaque =YES;
19 [c release];
20 [v release];


转自http://blog.csdn.net/zltianhen/article/details/6855768

posted @ 2012-02-22 11:01  woainilsr  阅读(905)  评论(0编辑  收藏  举报