I want to use my self background for my UIToolbar.
To do that with the UINavigationBar I’ve just used this category with the override of the drawRect method:
@implementation UIToolbar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"nm010400.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
This piece of code works perfectly for the UINavigationBar but this does not work for the UIToolbar that is inncluded in the UINavigationController and enabled with this line o code:
self.navController.toolbarHidden = NO;
Can anyone help me with the problem? I’ m sure that the UINavigationController use a standard UIToolbar so why this not works?!? thanks
To create custom UI elements there is no need to create categories anymore. With IOS 5 you can change the appearance of any UI element through the UIApperance protocol. You can change individual UI elements as normal but the real power comes when you are creating a themed application. Using this new protocol you can change the style of all instances of a particular UI element or even a UI element in a particular setting such as a UIBarButtonItem in a UINavigationController.
To change the appearance of all of the UINavigationBars in your application you can set the background like so,
you change different attributes depending on which element you are using to change the title attributes of the UINavigationBar you can use,
you can also use this on other UI elements so to change the background on all instances of the UIToolbar you can call
Hope this helps.