Ramotion / animated-tab-bar

:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
https://www.ramotion.com/animated-tab-bar-ios-app-development-ui-library/
MIT License
11.12k stars 1.33k forks source link

First tabbarItem Text tintColor is wrong #292

Closed ShenYj closed 3 years ago

ShenYj commented 3 years ago

I have two demo target:

  1. set up windows's rootViewController with custom UITabBarController
  2. set up other ViewController and change the rootViewController to custom UITabBarController by the lib named "SwifterSwift"

now, the first demo is correct, but the second demo with the bug that the first tabBarItem's text selectedColor is the default blue!

I try to set up the rootViewController with custom UITabBarController directly, but it was not work!

I have to set tabBar's tintColor before set the child controllers, and the first demo I have nothing to do , but it work well!

ikolpachkov commented 3 years ago

@ShenYj hey, please take a look at RAMItemAnimation it has @IBInspectable open var textSelectedColor: UIColor @IBInspectable open var iconSelectedColor: UIColor

To update unselected state you can use RAMAnimatedTabBarItem @IBInspectable open var textColor: UIColor @IBInspectable open var iconColor: UIColor

Hope this would help you 🤞🏻 If not you can provide source code with your examples

ShenYj commented 3 years ago

hey, please take a look at RAMItemAnimation it has @IBInspectable open var textSelectedColor: UIColor @IBInspectable open var iconSelectedColor: UIColor

thks for your reply.

I use it in my project without xib/storyboard, Now it had been fixed!

here is my code:

internal class MainTabController: RAMAnimatedTabBarController {

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        // fix: The first item label tintColor is wrong after changed the selected item ( 切换到TabBar控制器后, 默认首个子标签高亮色错误)
        addAllChildsControllors()
        super.viewDidLoad()
        tabBar.tintColor = UIColor.highLightColor()
        view.backgroundColor = UIColor.viewBackgroundColor()
    }
}