0

I'm using storyboard and a TabBarNavigation Controller. The View Controller of the tabs are embedded in NavigationController. I didn't set the image of the first TabBarItem in the storyboard.

  1. The png files don't show up. Only a gray square is shown, so maybe the size needs to be changed.
  2. If I select the second tab the png file in the first tab will be shown in the correct size.

I couldn't figure that out with the documentation. How do I have to adjust the image or what do I have to do?

    var tabBarItem1 :       UITabBarItem
    var image1 = UIImage(named: "feed.png")
    var image2 = UIImage(named: "feed_chosen.png")


    tabBarItem1 = tabBar.items[0] as UITabBarItem
    tabBarItem1.title = "Feed"

    image1.drawInRect(CGRect(x: 0, y: 0, width: 40, height: 30))


    tabBarItem1.image = image1
    tabBarItem1.selectedImage = image2
Joe
  • 207
  • 1
  • 2
  • 9

1 Answers1

-2

Here is a link to some info on how to customize UITabBarController tab images in iOS 7+: http://appplusme.tumblr.com/post/68723979500/adding-a-custom-selected-uitabbaritem-image-in-ios7

And, of course, there's always Apple's docs: https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarController_Class/Reference/Reference.html

Austen Chongpison
  • 3,966
  • 1
  • 20
  • 17