Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Selected Image in Tab Bar Controller with Storyboard

Tags:

ios

xcode5

I am using Storyboarding and I have a tab bar controller with five tabs. In the storyboard, I am able to set the image for the tab bar item. Apple docs suggest to have two icons for each tab bar item - one for selected and one for the unselected state.

I am not able to figure out how I can do this using storyboard.

like image 283
Siddharth Avatar asked Jan 27 '14 16:01

Siddharth


2 Answers

You can use storyboard to set selected image of tabbar. I tried and it worked for me. Select the UITabbarItem and add a run-time attribute 'selectedImage', select Type as 'Image' and give the name of your image as its value.

Setting selected image of Tabbar using storyboard

I am using XCode 6.0 and my minimum deployment target is iOS 8.0.

like image 90
Hamza Azad Avatar answered Oct 19 '22 12:10

Hamza Azad


Here is complete solution for selected/unselected image in Tabbar For XCode >= 8:

  • Go to Image assets -> select image
  • Select Render AS: "Original Image"

enter image description here

  • After that go to storyboard -> Select Tabbar Item
  • Under Attribute Inspectors, set "Selected Image" & "Image" as shown in following screenshot, that`s it:

enter image description here

like image 45
Sagar Sukode Avatar answered Oct 19 '22 12:10

Sagar Sukode