Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-01-2010, 08:32 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 66
hatembr is on a distinguished road
Default setting a custom navigation bar background also changes Movie Player nav bar

hi,

I am using this code to change the Navigation Controller's nav bar :

Code:
// custom nav bar background
@implementation UINavigationBar (UINavigationBarCategory)

- (void)drawRect:(CGRect)rect {
	
	UIDeviceOrientation o = [[UIDevice currentDevice] orientation];
	
	CGContextRef context = UIGraphicsGetCurrentContext();
	
	CGContextSaveGState(context);
	CGContextTranslateCTM(context, 0, self.frame.size.height);
	CGContextScaleCTM(context, 1.0, -1.0);
	
	
	// Drawing code	
	
	if ( (o == UIDeviceOrientationLandscapeLeft) || (o == UIDeviceOrientationLandscapeRight)) {
		UIImage *img = [UIImage imageNamed: @"v2-header-landscape.png"];
		CGContextDrawImage(context, CGRectMake(0, 0, 480, self.frame.size.height), img.CGImage);
	}
	else {
		UIImage *img = [UIImage imageNamed: @"v2-header.png"];
		CGContextDrawImage(context, CGRectMake(0, 0, 320, self.frame.size.height), img.CGImage);
	}
	
	
	CGContextRestoreGState(context);
	
}
@end
This code changes the background of the nav bar in every pushed controller, including the Movie Player.

Any idea how to prevent this ?
hatembr is offline   Reply With Quote
Old 09-04-2010, 06:32 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 66
hatembr is on a distinguished road
Default

ok guys, here is a link that may be very helpful for those who may fall in the same situation :

Adding a Background Image to UINavigationBar | SebastianCelis.com

I didn't try this solution yet, but I think it is THE one I was looking for to have a custom background in the nav bars without affecting the movie player's one.

I used to use drawRect but in this article, the author clearly explains that this method will override every nav bar in the app.

so hope this helps.
hatembr is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 351
7 members and 344 guests
dre, freewind, hain, HemiMG, lendo, mottdog, oceanlablight
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0