iOS -- 导航栏和标签栏的一些设置


UINavigationBar && UITabbarItem相关

设置导航栏字体的大小以及颜色

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:16]}];

设置标签栏字体的大小和选中颜色

- (void)setupTabbarItemProperty:(UITabBarItem *)tabbarItem{
    //改变字体颜色
    [tabbarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor],NSFontAttributeName:[UIFont systemFontOfSize:12]} forState:UIControlStateNormal];

    //选中状态颜色
    [tabbarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor greenColor],NSFontAttributeName:[UIFont systemFontOfSize:12]} forState:UIControlStateSelected];
}

设置导航栏返回按钮保留箭头 去除文字

标准答案:

//方法 一 :
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
 forBarMetrics:UIBarMetricsDefault];
//方法 二 :
UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iOS7BackButton"] style:UIBarButtonItemStylePlain target:self action:@selector(goToPrevious:)];
self.navigationItem.leftBarButtonItem = barBtnItem;

等多个方案……

设置界面跳转时隐藏tabbar

- (void)pushToViewController:(UIViewController *)itemVC{
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:itemVC animated:NO];
    self.hidesBottomBarWhenPushed = NO;
}

你可能感兴趣的:(iOS--视图控件,iOS--常用代码块)