iOS UINavigationController常用实用设置汇总

文章目录

  • NavigationBar设置

NavigationBar设置

-(void)setNavigationBarWithTitle:(NSString*)title{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    //返回按钮去掉文字
    //self.navigationController.navigationBar.topItem.title = @"";
    self.edgesForExtendedLayout = 0;
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.navigationItem.title = title;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    //隐藏单个页面(控制器)的返回按钮
    UIBarButtonItem *leftItem=[[UIBarButtonItem alloc]init];
    leftItem.title=@"";
    self.navigationItem.leftBarButtonItem=leftItem;
    //添加item
    UIBarButtonItem *rightBarButtonItem=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(clickRightBtn)]; self.navigationItem.rightBarButtonItem=rightBarButtonItem;
}

你可能感兴趣的:(IOS)