标签:style blog color io ar sp div c on
代码:
可任选一套方法进行显示和隐藏,如果决定有动画的那套,那么一开始初始化时就必须用set方法进行控制
-(void) setBar { UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil]; UIBarButtonItem *searchButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:nil]; self.navigationItem.leftBarButtonItems = @[addButton, searchButton]; UIBarButtonItem *organizeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:nil]; [self setToolbarItems:@[organizeButton]]; } -(void) showBar { // 无论哪套设置方法都可以这么判断是否隐藏 if (self.navigationController.navigationBar.hidden) { NSLog(@"show it"); // 两套隐藏方法,这套无动画,不可混用 //self.navigationController.navigationBar.hidden = NO; //self.navigationController.toolbar.hidden = NO; // 有动画 [self.navigationController setNavigationBarHidden:NO animated:YES]; [self.navigationController setToolbarHidden:NO animated:YES]; } else { NSLog(@"hide it"); [self.navigationController setNavigationBarHidden:YES animated:YES]; [self.navigationController setToolbarHidden:YES animated:YES]; } } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setBar]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self showBar]; }
标签:style blog color io ar sp div c on
原文地址:http://www.cnblogs.com/code-style/p/4002417.html