I'm adding a custom background image to my UINavigationBar by overriding the drawRect via a category.
- ( void )drawRect:( CGRect )rect{ [[UIImage imageNamed:@"navbar.png"] drawInRect:CGRectMake( 0, self.frame.size.height-44, self.frame.size.width, 44 )]; }
This solution seems to work fine, until you try to make use of navigationitem.prompt property.
Instead of doing a smooth animation of presenting the prompt, it does it abruptly.
Are there any suggestions on how to remedy this ? Or an alternative way of setting a background image.
PS. I'm trying to avoid just adding a background image as a subview because of the way things rearrange when views push/pop. And I'd hate to sendSubviewToBack in every view's viewDidAppear.
TIA!
EDIT: I also tried method swizzling, which would work fine if I could just let my image stretch, but since the image isn't stretchable, I need to figure out how to tap into the animation that happens to do a shift instead of a stretch.
EDIT: see my hacky answer below
Best Answer
So very "hacky", but this is the closest I can get it to do what I want...
Basically when method swizzling, simply letting the image stretch wasn't working well for me because I also had rounded corners. So instead I made the corners a separate transparent img and add it as a subview so they wouldn't get affected by the stretch animation.
So my category now looks like this..
for more on method swizzling... http://www.cocoadev.com/index.pl?MethodSwizzling and Method Swizzle on iPhone device