程序员iOS Developer

关于iOS开发中UINavigationController的常

2016-12-21  本文已影响30人  KennyHito
个人链接
微信公众号.jpg
问题1:导航栏隐藏和显示
#pragma mark -- 将导航栏隐藏
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];//隐藏导航栏
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];//去除黑线
}
#pragma mark -- 将导航栏归还原样
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];//显示导航栏
    [self.navigationController.navigationBar setShadowImage:nil];//加上黑线 
}
问题2:统一设置导航栏颜色和导航栏字体的颜色
//统一设置导航栏样式,文字颜色及其大小
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance]setTitleTextAttributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:17]}];
[[UINavigationBarappearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColorwhiteColor],NSFontAttributeName:[UIFontboldSystemFontOfSize:20]}];
问题3:关于iOS自定义返回按钮右滑返回手势失效的解决
self.navigationController.interactivePopGestureRecognizer.delegate=(id)self;
时间: 2016.12.21 16:51
声明
上一篇下一篇

猜你喜欢

热点阅读