Reputation: 11550
I want to change the color of UINavigationBar
, color will be taken from an image.
Upvotes: 2
Views: 9473
Reputation: 915
There is a way to do this from storyboard in xcode 6.4.
From the document outline select Navigation bar
Than from attribute inspector change bar tint
You can also pick other and this will bring the color picker
Pick the dropper and this will let you pick a color from an image
Upvotes: 0
Reputation: 13267
In iOS 7 or later, try the following:
navigationBar.barTintColor = [UIColor redColor];
Upvotes: 2
Reputation: 720
Try this:
CustomNavBar
inherited UINavigationBar
class...MainWindow.xib
and change the UINavigationBar class to
CustomNavBar`.The code:
@implementation CustomNavBar (CustomNavBarCategory)
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
if([self isMemberOfClass:[CustomNavBar class]])
{
UIImage *image;
image=[UIImage imageNamed:@"ImageName"];
CGContextClip(ctx);
CGContextTranslateCTM(ctx, 0, image.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextDrawImage(ctx,CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage);
}
else
{
[super.layer drawLayer:layer inContext:ctx];
}
}
@end
Upvotes: 0
Reputation: 12780
try to set the objects as subviews to the navigationBar.
Set the tint color property or use images
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:rootController];
controller.navigationBar.tintColor = [UIColor blackColor];
Upvotes: 6
Reputation: 4463
If you are supporting only iOS5 and later, you can use "appearance proxy". There is a good tutorial for this.
If you have to support prior versions, you have to subclass UINavigationBar
and override its drawRect
method. There is a good sample code for this.
Upvotes: 1