Skip to content

Instantly share code, notes, and snippets.

@calosth
Created May 6, 2018 22:34
Show Gist options
  • Save calosth/aec9604d12e10478b287f31b177c1d15 to your computer and use it in GitHub Desktop.
Save calosth/aec9604d12e10478b287f31b177c1d15 to your computer and use it in GitHub Desktop.
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
}
}
@kunwar231
Copy link

what is indicatorImage?

@calosth
Copy link
Author

calosth commented Jun 23, 2021

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