Our thinking

Titanium – How to remove navigation bar drop shadow in iOS 6

10 July 2013

Normally, Titanium doesn’t provide the necessary options to remove the navigation bar shadow (as shown below). But our client preferred a nav bar without the shadow so I figured out it could be removed by modifying the Titanium iOs code.


Here’s how it works:

Open your app in Xcode and locate the file Classes>Modules>UI>iOs>iPhone>Nav Group>TiUIiPhoneNavigationGroup.m:

simply add the following to the “controller” function

controller.navigationBar.clipsToBounds = YES;  

so it looks like the following:

-(UINavigationController*)controller
{
	if (controller==nil)
	{
		TiWindowProxy* windowProxy = [self.proxy valueForKey:@"window"];
		if (windowProxy==nil)
		{
			[self throwException:@"window property required" subreason:nil location:CODELOCATION];
		}
		UIViewController *rootController = [windowProxy controller];	
		controller = [[UINavigationController alloc] initWithRootViewController:rootController];
		[controller setDelegate:self];
                controller.navigationBar.clipsToBounds = YES;        
		[self addSubview:controller.view];
		[controller.view addSubview:[windowProxy view]];
		[windowProxy prepareForNavView:controller];
		
		root = windowProxy;
//		[self setVisibleProxy:windowProxy];
	}
	return controller;
}

Recompile your app and that’s it, the shadow is gone (woo!):