iPhone Programmatically
iPhone Programmatically

Reputation: 1227

How to add image to UITabBarController

I am using UITabBarController and want to add image to it, a whole image to tab bar, not to any tab item. Is it possible, can anyone guide. Thanks in advance.

Upvotes: 1

Views: 1773

Answers (2)

Midhun MP
Midhun MP

Reputation: 107131

If you are using iOS 5 or greater you can use setBackgroundImage:

UITabBar *yourtabBar = [yourtabController tabBar];

[yourtabBar setBackgroundImage:[UIImage imageNamed:@"tabbar.jpg"]];

Upvotes: 0

Wolverine
Wolverine

Reputation: 4329

Try this. May be it help

 UIImage *tabBackground = [[UIImage imageNamed:@"Your Image"] 
                          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];

Upvotes: 2

Related Questions