Shadberrow
7/10/2017 - 5:41 AM

animate tab bar images

animate tab bar images

    override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
        if item.tag == 0 {
            self.animateTabBar(self.mainTabBar.subviews[1].subviews.first!)
        } else if item.tag == 1 {
            self.animateTabBar(self.mainTabBar.subviews[2].subviews.first!)
        } else if item.tag == 2 {
            self.animateTabBar(self.mainTabBar.subviews[3].subviews.first!)
        }
    }
    
    func animateTabBar(_ item: UIView) {
        item.transform = CGAffineTransform(scaleX: 2, y: 2)
        UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.5, options: .curveEaseOut, animations: {
            item.transform = CGAffineTransform.identity
        }, completion: nil)
    }