Ok, this has been frustrating me to no end!
All I want is a simple navigation bar with the buttons a different color tint than the bar itself. Should be easy enough. See image below
My current apps got the job done perfectly with this code added to the root delegate:
Code:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"greenGradient.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.tintColor = [UIColor colorWithRed:.8 green:.7 blue:0 alpha:1];
}
That code works perfectly and gives me the perfect effect. Only problem is now with the latest version of xcode it not letting me compile it because its a bit of a hack. Even though the code works perfectly, the compiler won't let me compile it.
So Question #1: Is there a way to force the compiler to skip these lines of code?
I've then tried this code:
Code:
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:.8 green:.7 blue:0 alpha:1]]; // <-- mustard
NSString *barBgPath = [[NSBundle mainBundle] pathForResource:@"greenGradient" ofType:@"png"];
[bar.layer setContents: (id)[UIImage imageWithContentsOfFile: barBgPath].CGImage];
that code works perfectly in the simulator, but on the device it simply makes the entire navigation bar yellow and doesn't show the green image at all.
I've tried dozens of "solutions" and none of them works. Has anyone been able to make this work??