1.下面這種隱藏導航欄? 本人在開發(fā)中使用時候發(fā)現(xiàn) 導航的透明設置NO? 才在push頁面沒有黑影閃現(xiàn),但是在本頁面使用本隱藏導航欄的方法時候再次push 一個隱藏的導航欄 會存在黑影的閃現(xiàn),由于在viewWillDisappear? 調用了 [self.navigationController setNavigationBarHidden:NO animated:animated]; 同時在viewWillAppear 調用[self.navigationController setNavigationBarHidden:YES animated:animated]; ?很短時間內連續(xù)調用這個兩個方法導致。
所以注意使用時的控制 ?。
- (void)viewWillAppear:(BOOL)animated{
? ? [super ?viewWillAppear:animated];
? ? [self.navigationController ?setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated{
? ?[super ?viewWillDisappear:animated];
? ?[self.navigationController ?setNavigationBarHidden:NO ?animated:animated];
}
2.后來本人使用 透明化導航欄 但是這里不會真正隱藏導航欄只是導航欄透明了而已,同時去除黑線,如果不是使用[self imageWithColor:[UIColor clearColor]? 而使用[[UIImage ?alloc]init] 那只是去除黑線
- (void)viewWillAppear:(BOOL)animated{
? ? ? [super ?viewWillAppear:animated];
? ? ? [self.navigationController.navigationBar? setBackgroundImage:[self imageWithColor:[UIColor clearColor]? forBarMetrics:UIBarMetricsDefault];
? ? ? [self.navigationController.navigationBar setShadowImage:[self ?imageWithColor:[UIColor? clearColor]]];
}
- (void)viewWillDisappear:(BOOL)animated{
? ? ? ? [super ? viewWillDisappear:animated];?
? ? ? ? [self.navigationController.navigationBar ? setBackgroundImage:nil ? ? ?forBarMetrics:UIBarMetricsDefault];
? ? ? ? [self.navigationController.navigationBar ? setShadowImage:nil];
}
- (UIImage*)imageWithColor:(UIColor*)color
{
? ?CGRect rect =CGRectMake(0.0f,0.0f,1.0f,1.0f);
? ?UIGraphicsBeginImageContext(rect.size);
? ?CGContextRef context =UIGraphicsGetCurrentContext();
? ?CGContextSetFillColorWithColor(context, [colorCGColor]);
? ?CGContextFillRect(context, rect);
? ?UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
? UIGraphicsEndImageContext();
? return image;
}