iphone - shadow effect for UINavigationbar like GameCenter -


i want add shadow effect uinavigationbar gamecenter.

i think apply background image shadow nav bar, title's line height down. , draw shadow background, background image not scroll.

what best practice of case??

you can subclass uinavigationcontroller , have shadow layer each navigation or if bar visible add shadow uiwindow (only 1 entire application) , make frontmost view each time add subview.

cgcolorref darkcolor = [[uicolor blackcolor] colorwithalphacomponent:.5f].cgcolor; cgcolorref lightcolor = [uicolor clearcolor].cgcolor;  cagradientlayer *newshadow = [[[cagradientlayer alloc] init] autorelease]; newshadow.frame = cgrectmake(0, self.navigationbar.frame.size.height, self.navigationbar.frame.size.width, 10); newshadow.colors = [nsarray arraywithobjects:(id)darkcolor, (id)lightcolor, nil];  [self.navigationbar.layer addsublayer:newshadow]; 

if choose latter case override didaddsubview make layer frontmost:

calayer *superlayer = self.shadowlayer.superlayer; [self.shadowlayer removefromsuperlayer]; [superlayer addsublayer:self.shadowlayer]; 

hope helps.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -