Coder Social home page Coder Social logo

Comments (1)

CearsKhush avatar CearsKhush commented on May 31, 2024

Replace following code

override public func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
    
        if let uSelf = self.tabBar as? SSCustomTabBar, let items = uSelf.items, let index = items.firstIndex(of: item), index != self.priviousSelectedIndex {
            
            
            let width = UIScreen.main.bounds.width/CGFloat(items.count)
            
            var changedIndex = 0
            
            if NSLocale.preferredLanguages[0].starts(with: "ar") {
                
                if index == 0 {
                    changedIndex = 5
                } else if index == 1 {
                    changedIndex = 4
                } else if index == 2 {
                    changedIndex = 3
                } else if index == 3 {
                    changedIndex = 2
                } else if index == 4 {
                    changedIndex = 1
                }
            } else {
                changedIndex = index + 1
            }

            let changeValue = (width*CGFloat(changedIndex))-(width/2)
                            
            uSelf.animating = true
            
            let orderedTabBarItemViews: [UIView] = {
                let interactionViews = tabBar.subviews.filter({ $0 is UIControl })
                return interactionViews.sorted(by: { $0.frame.minX < $1.frame.minX })
            }()
            
            orderedTabBarItemViews.forEach({ (objectView) in
                let objectIndex = orderedTabBarItemViews.firstIndex(of: objectView)
                
                
                if index ==  objectIndex {
                    print(index)
                }else if  objectIndex == priviousSelectedIndex {
                    UIView.animate(withDuration: 0.9, delay: 0.0, usingSpringWithDamping: 0.57, initialSpringVelocity: 0.0, options: .curveEaseInOut, animations: {
                        objectView.frame = CGRect(x: objectView.frame.origin.x, y: objectView.frame.origin.y + self.kUpAnimationPoint, width: objectView.frame.width, height: objectView.frame.height)
                    }, completion: nil)
                }
            })
            self.priviousSelectedIndex = index
            performSpringAnimation(for: orderedTabBarItemViews[index], changeValue: changeValue)
            
    }
    
}

from sscustomtabbar.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.