Closed bahlo closed 5 years ago
I assume you are using an IBOutlet, the code should be something like this:
#import "ViewController.h"
#import "CRGradientNavigationBar.h"
@interface ViewController ()
@property (nonatomic, weak) IBOutlet CRGradientNavigationBar *navigationBar;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *colors = [NSArray arrayWithObjects:(id)[UIColor redColor].CGColor, (id)[UIColor orangeColor].CGColor, nil];
[self.navigationBar setBarTintGradientColors:colors];
}
Thanks for your answer.
I'm not using an IBOutlet, I'm extending UINavigationController, so self.navigationBar
already exists and already has the class CRGradientNavigationBar
(via Storyboard).
I have recently started from scratch with code-only and have exactly the same problem.
I copy-pasted the full example from the README
and it only takes the second color (same problem).
And I tried different View- and NavigationControllers but no changes.
Maybe a few words about my environment help:
When I NSLog the navigationController.navigationBar
, I get this output:
<CRGradientNavigationBar: 0x10972eab0; baseClass = UINavigationBar; frame = (-512 0; 1024 44); autoresize = W; gestureRecognizers = <NSArray: 0x109732c00>; layer = <CALayer: 0x10972e970>>
The thing, that I find really strange is: On any iPhone app it just works (and looks great, btw.).
Sorry, I didn't have enough time to replicate this bug, I'll look into it, I promise. :)
Your last comment did not age well, haha. Closing since it's no longer an issue for me.
I set the class
CRGradientNavigationBar
to the NavigationBar in my Storyboard.Then in my custom UINavigationController class I do this in the viewDidLoad:
The bar changes it's color, but only to the second one provided.
Thanks in advance.