Closed prnk28 closed 9 months ago
if you want to change the colour dynamically for only one View Controller you can use:
[[CRGradientNavigationBar appearance] setBarTintColors:colors];
This also works with an UINavigationBar IBOutlet (w/o an UINavigationController): Place a navigation bar onto your view in IB. In IB set the navigation bar class to CRGradientNavigationBar (Same steps if you are using Storyboards). http://stackoverflow.com/questions/19174542/initwithnavigationbarclass-for-uinavigationcontroller-in-a-storyboard-applicatio
Also, if you choose to use a Navigation Controller (as the example). Hide the bar on the first screen, show the bar on the second screen or something like this using the viewWillAppear: and viewWilDisappear: methods of your UIViewController as a good place to control the visibility of the navigation controller's bar.
Hope it helps.
@chroman, with my experience, this is not 100% dynamic. If I call [[CRGradientNavigationBar appearance] setBarTintColors:colors];
after I call [[CRGradientNavigationBar appearance] setBarTintGradientColors:colors];
it stays on the gradient and does not go to a flat color.
Any way to get this to work?
I ended up solving the issue that I needed. After checking out this pull request, I pulled down the master branch of the pull request and ran the demo and learned:
UIColor *firstColor = [UIColor colorWithRed:255.0f/255.0f green:42.0f/255.0f blue:104.0f/255.0f alpha:1.0f];
UIColor *secondColor = [UIColor colorWithRed:255.0f/255.0f green:90.0f/255.0f blue:58.0f/255.0f alpha:1.0f];
NSArray *colors = [NSArray arrayWithObjects:firstColor, secondColor, nil];
CRGradientNavigationBar *bar = (CRGradientNavigationBar *)self.navigationController.navigationBar;
[bar setBarTintGradientColors:colors];
instead of:
[[CRGradientNavigationBar appearance] setBarTintColors:colors];
Thank you
Thanks for the help guys - I was 16 when I asked this time to close this issue 🤣
How would you change the view controller for only one View Controller rather than the whole application