3
我有一個UIAppearance設置爲我的導航欄。UIViewController插入UINavigationController堆棧失去UIAppearance設置
[[UINavigationBar appearance] setTitleTextAttributes: [self navigationBarTitleTextAttributes]];
-(NSDictionary *)navigationBarTitleTextAttributes
{
// UINavigationBar title
NSNumber *navBarTitleShadowOpacity = [self.personalityDictionary objectForKey:kNavBarTitleShadowOpacity];
UIColor *navBarTitleColor = [UIColor colorWithHexString: [self.personalityDictionary objectForKey:kNavBarTitleColor] alpha:1.0f];
UIColor *navBarTitleShadowColor = [UIColor colorWithHexString:[self.personalityDictionary objectForKey:kNavBarTitleShadowColor] alpha: [navBarTitleShadowOpacity floatValue]];
return [NSDictionary dictionaryWithObjectsAndKeys:
navBarTitleColor, UITextAttributeTextColor,
navBarTitleShadowColor, UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
nil];
}
所有的作品完美。在我的應用程序中,我需要將視圖控制器插入堆棧並彈出。
ChatsViewController* chatsViewController = [[ChatsViewController alloc] init];
NSMutableArray *mutableViewControllers = [self.navigationController.viewControllers mutableCopy];
[mutableViewControllers insertObject: chatsViewController atIndex: [mutableViewControllers count] - 1];
[self.navigationController setViewControllers: mutableViewControllers animated: NO];
[self.navigationController popToViewController: chatsViewController animated: YES];
此時,標題欄會丟失外觀設置並返回到默認白色。任何推入堆棧的新視圖控制器也會失去其外觀。
有什麼問題?
這就是我正在做的 - 我的AppearanceManager類在我的導航控制器設置之前運行。 –