I'm having fun learning to build my first iPhone app and wonder if someone would kindly point me in the right direction.
I have basically added in custom icons for my tab bar (IOS 7). Now I want to add in a custom selected state icon for each of these. How would I do this?
Thanks
Shell
As of Xcode 6, you can do this by default in Interface Builder. No need for any custom subclasses or categories as before.
Here is the swift solution based on @MrAlek's solution, create a custom UITabBarItem
import UIKit
@IBDesignable
class YourTabBarItem: UITabBarItem {
@IBInspectable var selectedImageName:String!{
didSet{
selectedImage = UIImage(named: selectedImageName)
}
}
}
and in interface builder, change the class of the tab bar item and you will see the Selected Image Name attribute, just specify your selected image name there. I reckon @IBInspectable is using the runtime attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With