christianroman / crgradientnavigationbar Goto Github PK
View Code? Open in Web Editor NEWCustom UINavigationBar subclass which allows gradient coloured navigation bar on iOS 7.
License: MIT License
Custom UINavigationBar subclass which allows gradient coloured navigation bar on iOS 7.
License: MIT License
I'm using storyboards so I don't use the App Delegate class to initialize my views. How would I implement the CRGradientNavBar then? Is it not possible?
[[UINavigationBar appearance] setTintColor:[~gradient~]]
Would be great to be able to have the gradient from left to right for instance.
The CRGradientNavigationBar
class could have a property named gradientDirection
which would be an enum CRGradientDirection
.
Cheers.
It is possible using gradient in this case?
EKEventEditViewController *controller2 = [[EKEventEditViewController alloc] initWithNavigationBarClass:[CRGradientNavigationBar class] toolbarClass:nil];
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 appearance] setBarTintGradientColors:colors];
[[controller2 navigationBar] setTranslucent:NO];
How would you change the view controller for only one View Controller rather than the whole application
I set the class CRGradientNavigationBar
to the NavigationBar in my Storyboard.
Then in my custom UINavigationController class I do this in the viewDidLoad:
UIColor *firstColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:255/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 appearance] setBarTintGradientColors:colors];
[self.navigationBar setTranslucent:NO];
The bar changes it's color, but only to the second one provided.
Thanks in advance.
My app is a Tab Bar Controller app, in which each tab is a NavigationController. I have my code set as:
`UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[CRGradientNavigationBar class] toolbarClass:nil];
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];
// or NSArray *colors = [NSArray arrayWithObjects:(id)UIColorFromRGB(0xf16149).CGColor, (id)UIColorFromRGB(0xf14959).CGColor, nil];
[[CRGradientNavigationBar appearance] setBarTintGradientColors:colors];
[[navigationController navigationBar] setTranslucent:NO]; // Remember, the default value is YES.
[navigationController setViewControllers:@[tabBarController]];
[self.window setRootViewController:navigationController];`
However, I am getting double navigation bars, with title and uibarbuttonitems being added to the 2nd, and not the gradient one. Any suggestions?
iOS7.1 later navigationbar color not set.
This library looks like a lifesaver! I need to do something exactly like this (with a translucent gradient), however, I need the gradient to be horizontal, rather than vertical. Is this supported? Or how could I extend this library to support this feature?
Hey croman,
Your navigation bar works great, but the colors that I include in the array show up much darker than they should. When I set both gradient colors to white (ffffff) then the nav bar is a solid gray.
Thanks for your help! I'm using storyboards.
Only the bottom color is present when the screen rotate, I guess we should have the gradient on landscape as well?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.