GithubHelp home page GithubHelp logo

christianroman / crgradientnavigationbar Goto Github PK

View Code? Open in Web Editor NEW
916.0 916.0 116.0 363 KB

Custom UINavigationBar subclass which allows gradient coloured navigation bar on iOS 7.

License: MIT License

Ruby 5.97% Objective-C 94.03%

crgradientnavigationbar's People

Contributors

christianroman avatar nebulafox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crgradientnavigationbar's Issues

Gradient not showing โ€“ only the second color

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.

Horizontal gradients?

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?

Totally different if set translucent yes

Downloaded the demo, on iOS 7, run it after just only set translucent = YES, it looks totally different from NO.

How to handle the actual effect of color gradient with translucent, which are like your screenshots.

img_1352

Double Navigation Bars

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?

ios simulator screen shot jan 15 2015 9 56 47 am

EKEventEditViewController don't work with Gradient

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];

Allow other directions

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.

Gradient colors showing as much darker than specified colors

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.

Modal view

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

Storyboards?

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~]]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.