views:

269

answers:

1

Hi,

I've customized my UINavigationBar with an image like that :

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

When I launch a video my custom NavigationBar (with the picture) is on the top or I would like to have the default navigationBar style when I'm playing a video.

I tried to hide the navigationBar with

[self.navigationController setNavigationBarHidden:YES animated:animated];

but it just remove the navigationBar in my controller but I still have the NavigationBar.png when I'm playing a video. I tried to set the barstyle but it doesn't work either ...

self.navigationController.navigationBar.barStyle = UIBarStyleDefault;

Could you help me ?

+1  A: 

You can do it by using an extern boolean variable say: isVideo;

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
    if(!isVideo){
       UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
       [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    }
    else{
       UIImage *image = [UIImage imageNamed: @"SimpleNavigationBarImage.png"];
       [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    }
}
@end

Hope this helps.

Thanks,

Madhup

Madhup
Hi Madhup and thank's for your answer. That could work but it will change the image of my NavigationBar instead of using the default one.
Lithium