首页 > 技术文章 > 导航栏的设置

yelan 2015-11-20 19:58 原文

 1 一:在AppDelegate中统一定制导航栏风格
 2  //设置导航栏颜色,标题字体和颜色,还有阴影效果
 3     [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:26/255.0 green:154/255.0 blue:215/255.0 alpha:1.0]];
 4     [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
 5     NSShadow *shadow = [[NSShadow alloc] init];
 6     shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
 7     shadow.shadowOffset = CGSizeMake(0, 1);
 8     [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
 9                                                            [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
10                                                            shadow, NSShadowAttributeName,
11                                                            [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:20.0], NSFontAttributeName, nil]];
12     //设置返回箭头为自定义图片
13     [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"返回箭头.png"]];
14     [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"返回箭头.png"]];
15 二:在每个界面单独设置返回时字体的位置,可以放在当前页面的ViewDidLoad中
16     UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init];
17     backItem.title=@"     用户登录";
18     self.navigationItem.backBarButtonItem = backItem;
View Code

 

推荐阅读