标签:
UINavigationBar *bar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 64)];
[bar setBackgroundImage:[UIImage imageNamed:@"blackbg"] forBarMetrics:UIBarMetricsDefault];
UINavigationItem *item = [[UINavigationItem alloc] init];
UIButton *backBarButton=[[UIButton alloc] initWithFrame:CGRectMake(0, 7, 30, 30)];
[backBarButton setBackgroundImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
backBarButton.showsTouchWhenHighlighted=YES;
[backBarButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem=[[UIBarButtonItem alloc] initWithCustomView:backBarButton];
item.leftBarButtonItem = backItem;
[bar pushNavigationItem:item animated:NO];
[self.view addSubview:bar];
UILabel * titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
titleLabel.backgroundColor=[UIColor clearColor];
titleLabel.font=[UIFont systemFontOfSize:18];
titleLabel.text=@"Etcast";
titleLabel.textAlignment=NSTextAlignmentCenter;
titleLabel.textColor=[UIColor whiteColor];
item.titleView=titleLabel;
标签:
原文地址:http://www.cnblogs.com/momosmile/p/5032999.html