Skip to content

Commit

Permalink
Merge pull request #10 from saiedkia/master
Browse files Browse the repository at this point in the history
added RTL language support
  • Loading branch information
askopin authored Sep 28, 2019
2 parents 1ec571b + 35c5066 commit 639b2cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
Binary file added .DS_Store
Binary file not shown.
38 changes: 26 additions & 12 deletions BubbleTabBar/Classes/CBTabBarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import UIKit

public class CBTabBarItem: UITabBarItem {
@IBInspectable public var tintColor: UIColor?
@IBInspectable public var rightToLeft:Bool = false
}

public class CBTabBarButton: UIControl {

var rightToLeft:Bool = false
private var _isSelected: Bool = false
override public var isSelected: Bool {
get {
Expand Down Expand Up @@ -63,9 +65,11 @@ public class CBTabBarButton: UIControl {
didSet {
tabImage.image = currentImage
tabLabel.text = item?.title
if let tabItem = item as? CBTabBarItem,
let color = tabItem.tintColor {
tintColor = color
if let tabItem = item as? CBTabBarItem {
if let color = tabItem.tintColor {
tintColor = color
}
rightToLeft = tabItem.rightToLeft
}
}
}
Expand Down Expand Up @@ -120,15 +124,25 @@ public class CBTabBarButton: UIControl {
tabBg.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
tabBg.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
tabBg.heightAnchor.constraint(equalToConstant: bgHeight).isActive = true


tabImage.leadingAnchor.constraint(equalTo: tabBg.leadingAnchor, constant: bgHeight/2.0).isActive = true
tabImage.centerYAnchor.constraint(equalTo: tabBg.centerYAnchor).isActive = true
tabLabel.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
csFoldedLblLeading = tabLabel.leadingAnchor.constraint(equalTo: leadingAnchor)
csUnfoldedLblLeading = tabLabel.leadingAnchor.constraint(equalTo: tabImage.trailingAnchor, constant: bgHeight/4.0)
csFoldedBgTrailing = tabImage.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -bgHeight/2.0)
csUnfoldedBgTrailing = tabLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -bgHeight/2.0)

if rightToLeft {
tabImage.trailingAnchor.constraint(equalTo: tabBg.trailingAnchor, constant: -bgHeight/2.0).isActive = true
tabImage.centerYAnchor.constraint(equalTo: tabBg.centerYAnchor).isActive = true
tabLabel.centerYAnchor.constraint(equalTo: tabBg.centerYAnchor).isActive = true
csFoldedLblLeading = tabLabel.leadingAnchor.constraint(equalTo: tabBg.trailingAnchor)
csUnfoldedLblLeading = tabLabel.leadingAnchor.constraint(equalTo: tabBg.leadingAnchor, constant: bgHeight/4.0)
csFoldedBgTrailing = tabImage.trailingAnchor.constraint(equalTo: tabBg.leadingAnchor, constant: bgHeight/2.0)
csUnfoldedBgTrailing = tabLabel.trailingAnchor.constraint(equalTo: tabImage.leadingAnchor, constant: -bgHeight/2.0)
} else {
tabImage.leadingAnchor.constraint(equalTo: tabBg.leadingAnchor, constant: bgHeight/2.0).isActive = true
tabImage.centerYAnchor.constraint(equalTo: tabBg.centerYAnchor).isActive = true
tabLabel.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
csFoldedLblLeading = tabLabel.leadingAnchor.constraint(equalTo: leadingAnchor)
csUnfoldedLblLeading = tabLabel.leadingAnchor.constraint(equalTo: tabImage.trailingAnchor, constant: bgHeight/4.0)
csFoldedBgTrailing = tabImage.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -bgHeight/2.0)
csUnfoldedBgTrailing = tabLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -bgHeight/2.0)
}

fold()
setNeedsLayout()
}
Expand Down

0 comments on commit 639b2cd

Please sign in to comment.