In Xcode 6, you now have the ability to set the icon for a tab item for its selected and unselected states. Please see the descriptions in the images below:
and
The only problem is that the image for the SELECTED states does not show. It just shows blank. Anyone else have this issue? Please see the screenshots below of the results:
and
Thanks!!!
So the way to go around this:
Set the tab with the default, unselected icon image you want to use in the "BAR ITEM" section in the Attributes Inspector:
Click on the Identity Inspector, and under "USER DEFINED RUNTIME ATTRIBUTES," click the + to add a new value.
KEYPATH: selectedImage (IT HAS TO BE THIS!!!)
TYPE: Image
VALUE: The name of your selected/highlighted icon image. I use Images.xcassets for my image assets.
Run your app. You'll notice that the image changes to the selected (not just highlighted version of it.
Works like a charm.
I want to add some info about the colored tab icon.
To change tab selection color:
Select the tabItem.
Set "tintColor" attribute with your prefer color.
Related
I've created a custom tab bar icon and made sure to set the background to transparent. The outline of the icon highlights when selected, but doesn't fill as system icons do.
From the Human Interface Guidelines manual:
Provide two versions of custom tab bar icons. Provide icons for both
the selected and unselected states. The selected icon is often a
filled-in version of the unselected icon, but some designs call for
variations to this approach.
My question is after I created the two versions of the icon as directed, how do you set it?
Using storyboard you need to select your tabViewController and define the tab item properties according your needs
Hope this helps you
I would like to have my tab bar similar to the App Store app (picture below). The active section has a coloured solid icon, and the other non-active sections will have the uncoloured outline icons. How can I switch from outline icon to solid icon depending on if it is selected or not? I would preferably want to accomplish this in interface builder but if thats not possible please explain how to do it in code. I have also provided a picture of my current tab bar. Notice how all of the icons are "outline" icons including the active section icon (I want the active section icon to be "solid"). I do have both the outline and solid icon sets, i'm just not sure how to use them both.
My current tab bar:
App Store tab bar (what I want but with my color not blue):
"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."
iamge that shows how it's done
Had the same problem, answer from here: Setting Selected Image in Tab Bar Controller with Storyboard
I am planning to make theme color of UI elements in application.
how we show custom color(Golden Color) like Black color in picker menu
is it possible? like we can add custom Property as shown in snapshot
You can add custom color as folow
Select color property(Background color, text color, etc.). A popup is shown from that select "other" option.
A color picker will be opened. Here you can set your custom color by RGB/Hex Code and you can set opacity.
The color will be applied and visible under "Recently Used Colors". This is how you can add custom colors but as far as I know you can't add colors in that default list.
Create a new palette by clicking "New" here:
A new palette "Unnamed" will be created. You can rename that palette by clicking the cog again and choosing "Rename..." Then, you'll need to click on the objects you want to capture the color of, and drag the color of those objects into the color chip area:
Once you've captured the color, you can even rename it something that indicates where it's normally used, providing more information to the recipient than just the color.
source
As of Xcode 9 you can add colors to your asset catalog.
Open your asset catalog, click the + and add a color set.
Click on the color that was created and you can name it and set the color using the inspector.
Thereafter that color shows up in storyboard color chooses in the area called Named Colors.
To achieve this follow these steps
*) In the Project navigator, select the asset catalog, click the Add button (+) at the bottom. In the pop-up menu, choose the type of asset set to create
*) then you'll see the color asset on storyboard.
Cheers :)
I have set in Storyboard tab bar item to be Custom, Image to my outline image and Selected image to my filled image but the selected image does not show up when I run the app.
It works if I create a tab bar item programmatically using
UITabBarItem(title: String?, image: UIImage?, selectedImage: UIImage?)
I use Xcode 6.1.1.
What can be wrong?
I think, it is a bug of Xcode, if you add a user defined runtime attribute with type Image and keyPath "selectedImage", you'll can set your image.
Here example of the Tabbed Application template with a custom selected image on the second tab (I use a image from the first tab):
This is more than likely because it doesn't meet the interface requirements. Tab bar items are picky, the strokes or outlines for a selected image have to be noticeably greater than its counterparts. See here specifically the notes about the stroke width. Conditionally, if it's not a 'filled' in variation of your unselected image it has a chance of not populating depending on you create the selected image in comparison.
As of Xcode 9, the functionality to set a selected image is available (and works) in interface builder.
I know how to change the image programatically when a button is pressed, but there must be a way to do this non programatically in Xcode, but despite searching high and low I simply cannot see anywhere in Xcode where the selected image can be specified.
Try in your storyboard. The second selection (STATE CONFIG) down in attributes inspector should show "default" for your button. Change the sate (Highlighted, selected, disabled) and then change the image in the image box 8 down or background image underneath.
Open up the "Attributes Inspector" in your storyboard or XIB and the image name is an attribute you can set in your UIButton object.
Also make certain to make the "Title" empty or a string will be drawn over your image.