I’ve read the “What’s new in iOS 5” documentation and there it is stated, that changing the background of some UI-Elements is now better supported.
I couldn’t find the correct way for iOS 5 to change the background image of an UIToolbar. Is there a special new iOS 5 way of doing this? Or do i still have to subclass the UIToolbar?
Yes, there is a new way to do this. You can use
appearanceto make allUIToolBars have the same appearance.First, you have to make sure your class follows the
UIAppearanceContainerprotocol. Here I have done it in my app delegate:Then you can set the appearance in, for example,
application:didFinishLaunchingWithOptions:orviewDidLoad. Like this:You only have to do this once to get the same appearance for all
UIToolBars in your app. You can also set many of (if not all?) the properties of yourUIToolBar.As a sidenote, there are many classes that can follow the
UIAppearanceContainerprotocol. To find out what can be customized using the appearance protocol, you can open the header file of the class you want to customize, if you can set a property withUIAppearance, then the property hasUI_APPEARANCE_SELECTORwritten behind the property declaration.