ale*_*mix 28 objective-c uinavigationbar ios
UINavigationBar在视图之间转换时,我遇到了重新配置iOS 7和8的问题.
我的应用程序目前包含以下UIViewController流程:
VC1 - > VC2 - > VC3
在这个流程中
UINavigationBarUINavigationBarUINavigationBar我遇到的问题是这些视图之间的转换看起来都非常草率.首先,我尝试了以下内容:
在VC2中
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// configure appearance
[self.navigationController.navigationBar configureTranslucentAppearance];
}
Run Code Online (Sandbox Code Playgroud)
并在VC1和VC3中
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// configure appearance
[self.navigationController.navigationBar restoreDefaultAppearance];
}
Run Code Online (Sandbox Code Playgroud)
以下是上面列出的两个辅助函数的实现:
- (void)restoreDefaultAppearance {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor JTTextNavBar]}];
[self setTintColor:[UIColor JTTextNavBar]];
[self setBarTintColor:[UIColor JTBackgroundNavBarWithAlpha:1.0]];
[self setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self setBackgroundColor:[UIColor JTBackgroundNavBarWithAlpha:1.0]];
[self setShadowImage:[UIImage navigationBarShadowImage]];
[self setTranslucent:NO];
}
- (void)configureTranslucentAppearance {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self setBackgroundColor:[UIColor clearColor]];
[self setShadowImage:[UIImage new]];
[self setTranslucent:YES];
}
Run Code Online (Sandbox Code Playgroud)
这是处理此转换的最基本方法.它有以下视觉文物:




这些过渡看起来都不好看.理想情况下,我希望视图与新的一起顺利过渡,UINavigationBar但我看到成功完成此操作的唯一方法是手动为每个xib添加一个工具栏.
有什么建议?抱歉,如果这种描述令人困惑:(
编辑:为每个列出的过渡添加了裁剪图像UINavigationBar和顶部UIViewController.
ale*_*mix 15
我终于找到了合适的解决方案!
似乎没有一种正确的方法可以从不透明平滑过渡到透明UINavigationBar但是您可以从具有可见状态栏的视图控制器平滑过渡到具有隐藏状态栏的视图控制器.
这开辟了一个可能的解决方法,其是添加在下面viewWillAppear的VC2以上从:
[self.navigationController setNavigationBarHidden:YES animated:YES];
Run Code Online (Sandbox Code Playgroud)
完成后,手动将UINavigationBarxib 添加到xib并将其配置为透明(并添加所有必需UIBarButtonItem和视图).
如果一切都正常连接从VC1转换到VC2将以UINavigationBar与视图转换相同的速度隐藏,VC2将显示其嵌入UINavigationBar
注意:为了使其正常工作,您必须确保在viewWillAppear可从VC2访问的视图控制器中,通过以下方式重置UINavigationBar可见(如有必要):
[self.navigationController setNavigationBarHidden:NO animated:YES];
Run Code Online (Sandbox Code Playgroud)
TL; DR - 手动添加UINavigationBar到透明导航栏视图控制器,并在其viewWillAppear隐藏默认的一个通过setNavigationBarHidden:animated:
Tom*_*ift 15
您看到的黑色是UINavigationController's视图的背景颜色.最小化视图的一种方法是将该视图的背景颜色操纵为传出/传入视图控制器视图的颜色.如果您使用纯色,这很有效.另一种方法是使用在不透明导航栏后面扩展您的视图UIViewController.extendedLayoutIncludesOpaqueBars = YES;
| 归档时间: |
|
| 查看次数: |
9068 次 |
| 最近记录: |