Closed HarshPandya136 closed 5 years ago
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)
}
}
Thank you in Advance
how can I manage tabs in arabic?