Search code examples
iphoneimageuitabbarcontrolleruitabbar

UITabBarController and UITabbar with background images for UIBarButon


Hello, please forgive me for asking very common question, I created uitoolbarcontroller in app delegate, and assign title for tabbar in view did load of view controller.

Code is here:

   [[self.tabBarController.tabBar.items objectAtIndex:0] setTitle:@"Exercise Dict."];

Please tell me how to set the image as background insted of title.

I added this in same method for background image:

 [[self.tabBarController.tabBar.items objectAtIndex:0] setBackgroundImage:[UIImage imageNamed:@"Beginner-1"]];

But its giving an error='NSInvalidArgumentException', reason: '-[UITabBarItem setBackgroundImage:]: unrecognized selector sent to instance 0xa25e9a0'.


Solution

  • Try this:

    self.tabBarController.tabBarItem.image=[UIImage imageNamed:@"yourimage.png"];