UITabBarItem Image doesn't show up

1.6k views Asked by At

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
1

There are 1 answers

0
Austen Chongpison On