我在新的视图控制器中使用RECurtainViewController进行转换。在我的app委托中,我设置了导航栏外观:
[[UINavigationBar appearance] setTitleTextAttributes: @{
UITextAttributeTextColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],
UITextAttributeFont: [UIFont fontWithName:@"Helvetica" size:20.0f]
}];
导航栏的根视图控制器可以正确显示。但是,当我使用:
引入新的视图控制器时DemoViewController *test = [[DemoViewController alloc] init];
[self curtainRevealViewController:test
transitionStyle:RECurtainTransitionHorizontal];
UINavigationBar外观设置回默认值。任何想法如何使自定义外观持续存在?
修改
我注意到,当显示DemoViewController时,我也在控制台中收到此警告:
Warning: Attempt to present <DemoViewController: 0x1ddaae70> on <ViewController: 0x1e892040> whose view is not in the window hierarchy!
但是,它仍然显示视图控制器。
答案 0 :(得分:0)
我最终通过进入DemoViewController中的viewDidLoad方法并将属性分配给实际的navBar实例来解决这个问题:
[self.navBar setTitleTextAttributes: @{
UITextAttributeTextColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],
UITextAttributeFont: [UIFont fontWithName:@"Helvetica" size:20.0f]
}];
不确定为什么我必须这样做,但似乎有效。