0

This may be the same issue as Pixate Freestyle: clear styleClass property does not reset style. But I can't tell.

I have styled a UINavigationBar and the title and left and right buttons. My view is a table view. When I select a cell I restyle the navbar when I push a new view on the stack.

When I pop the view, I want the old style to take effect. However the buttons does not get restyled.

CSS:

navigation-bar {
    opacity: 1;
    color: black;
    background-color: white;
}
navigation-bar title {
    color: black;
}
navigation-bar button-appearance {
    color: black;
}


navigation-bar.he {
    background-color: darkgreen;
    color: white;
}
navigation-bar.he button-appearance {
    color: white;
}
navigation-bar.he title {
    color: white;
}

Pushing a new view controller works:

-(void)viewDidLoad {
    self.navigationController.navigationBar.styleClass = [self.dict objectForKey:CLASS]; // Imagine this is he
}

Popping the view controller and going back to the parent viewController:

-(void)viewWillAppear:(BOOL)animated
{
    // This updates the bar and title but not the buttons
    self.navigationController.navigationBar.styleClass = @"";
    [self.navigationController.navigationBar updateStyles];
    [self.navigationController.navigationItem updateStyles];
    [self.navigationItem.rightBarButtonItem updateStyles];

    /* Hack ...
    if(self.navigationItem.rightBarButtonItem!=nil)
        self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor];
    if(self.navigationItem.leftBarButtonItem!=nil)
        self.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
    */
}
Community
  • 1
  • 1
Megasaur
  • 626
  • 8
  • 20

1 Answers1

0

I found the answer here: Styling UINavigationBar Part 2

I was using the docs on the Freestyle website and trying to use button-appearance.

The correct style is now right-bar-button and left-bar-button.

navigation-bar {
    opacity: 1;
    color: black;
    background-color: white;
}
navigation-bar title {
    color: black;
}
navigation-bar right-bar-button, navigation-bar left-bar-button  {
    color: black;
}

navigation-bar.he {
    background-color: darkgreen;
    color: black;
}
navigation-bar.he title {
    color: black;
}
navigation-bar.he right-bar-button, navigation-bar.he left-bar-button  {
    color: black;
Megasaur
  • 626
  • 8
  • 20