self.navigationItem.hidesBackButton = YES;
如果显示出来就是:
self.navigationItem.hidesBackButton = NO;
我之前做的一个需求就是根据从不同地方回退这个界面的时候,左上的返回按钮,不同一个是自定义的。一个是系统的。这个时候就需要动态的调整了:
首先是自定义的:
UILabel *btnChapter = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];//左边打开侧滑的按钮 // btnChapter.font = [UIFont fontWithName:@"tkappicon" size:20]; [btnChapter setText:@"返回"]; btnChapter.userInteractionEnabled = YES; UITapGestureRecognizer *chapterTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(leftTouchUpInside:)]; [btnChapter addGestureRecognizer:chapterTapGestureRecognizer]; btnChapter.textColor = [UIColor colorWithRed:255.0/255 green:255.0/255 blue:255.0/255 alpha:1]; UIBarButtonItem* item=[[UIBarButtonItem alloc]initWithCustomView:btnChapter]; self.navigationItem.leftBarButtonItem = item; 然后是隐藏自定义,显示系统自带的:self.navigationItem.leftBarButtonItem = nil; self.navigationItem.hidesBackButton = NO;