christianroman / CRGradientNavigationBar

Custom UINavigationBar subclass which allows gradient coloured navigation bar on iOS 7.
MIT License
914 stars 116 forks source link

Modal view #3

Open gbmksquare opened 10 years ago

gbmksquare commented 10 years ago

I have CRGradientNavigationBar set to translucnet=NO, and it works great.

But when I call a modal view which also has translucent=NO the color gets darker.

How can I have modal view get the same color?

Navigation bar ios simulator screen shot 2014 1 2 12 59 28

Navigation bar in modal view ios simulator screen shot 2014 1 2 12 59 31

christianroman commented 10 years ago

I'm trying to solve the problem.

I'm not sure if this could solve your problem. A temporally solution for me is (example):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YourViewController *yourViewController = [[YourViewController alloc] init];

    UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[CRGradientNavigationBar class] toolbarClass:nil];
    [[navigationController navigationBar] setTranslucent:NO];

    // Notice that you don't need to reconfigure the gradient colors    

    [navigationController setViewControllers:@[yourViewController]];

    [self.navigationController presentViewController:navigationController animated:YES completion:nil];

    //[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

This is not the best solution. I'm working on it.

gbmksquare commented 10 years ago

This solution didn't work out for me..

I'm using IBAction on the gear icon on the first picture to present the modal view.

In storyboard, I've set navigation bar in parent view controller to CRGradientNavigationBar, and also navigation bar in modal view to CRGradientNavigationBar.

If translucency is set to NO in modal view, the color is dark no matter what parent translucency is.