开发者

Remove Custom UINavigationBar

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开发者_JAVA百科: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 ?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜