Created
May 6, 2018 22:34
-
-
Save calosth/aec9604d12e10478b287f31b177c1d15 to your computer and use it in GitHub Desktop.
This is a piece of the implementation of this post https://medium.com/@JillevdWeerd/bringing-animation-to-uitabbarcontroller-1b8780ced374
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { | |
let index = CGFloat(integerLiteral: tabBar.items!.index(of: item)!) | |
let itemWidth = indicatorImage?.frame.width | |
let newCenterX = (itemWidth! / 2) + (itemWidth! * index) | |
UIView.animate(withDuration: 0.3) { | |
self.indicatorImage?.center.x = newCenterX | |
} | |
} |
It's basically a horizontal line below the tab that is selected. You can refer to the Medium articule to get more context
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is indicatorImage?