I created a UITabBarController
with storyboard for iOS5. I don't have the UITabBar
declared in my ViewController and I can't set background image for tab bar.
UIImage *tabBackground = [[UIImage imageNamed:@"tabBarBackground.jpg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Set background for all UITabBars
[[UITabBar appearance] setBackgroundImage:tabBackground];
// Set background for only this UITabBar
[[tabBarController tabBar] setBackgroundImage:tabBackground];
You'll need to designate tabBarController
as an IBOutlet property
@property (nonatomic, strong) IBOutlet UITabBarController *tabBarController;
Then wire them up in the Connections inspector in Interface Builder, and you'll be able to use your code as shown.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.