Skip to content

Commit

Permalink
support right to left direction
Browse files Browse the repository at this point in the history
  • Loading branch information
igork-ramotion committed May 20, 2020
1 parent 2ea00f8 commit 5217424
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RAMAnimatedTabBarController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RAMAnimatedTabBarController'
s.version = '5.1.0'
s.version = '5.2.0'
s.license = 'MIT'
s.summary = 'RAMAnimatedTabBarController is a Swift module for adding animation to tabbar items.'
s.homepage = 'https://github.com/Ramotion/animated-tab-bar'
Expand Down
11 changes: 10 additions & 1 deletion RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ open class RAMAnimatedTabBarController: UITabBarController {

private func layoutContainers() {
let itemWidth = tabBar.bounds.width / CGFloat(containers.count)
let isRTL = tabBar.userInterfaceLayoutDirection == .rightToLeft

for (index, container) in containers.enumerated() {
let frame = CGRect(x: itemWidth * CGFloat(index), y: 0, width: itemWidth, height: Theme.tabBarHeight)
let i = isRTL ? (containers.count - 1 - index) : index
let frame = CGRect(x: itemWidth * CGFloat(i), y: 0, width: itemWidth, height: Theme.tabBarHeight)
container.frame = frame

if let item = tabBar.items?.at(index) as? RAMAnimatedTabBarItem {
Expand Down Expand Up @@ -323,3 +325,10 @@ extension RAMAnimatedTabBarController {
public static let defaultIconVerticalOffset: CGFloat = -5
}
}


extension UIView {
var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection {
return UIView.userInterfaceLayoutDirection(for: self.semanticContentAttribute)
}
}

0 comments on commit 5217424

Please sign in to comment.