Skip to content

Commit 3934625

Browse files
committed
Added currentTab
1 parent d9ad21d commit 3934625

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Sources/AZTabBarController.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,6 @@ public class AZTabBarController: UIViewController {
182182
self.buttonsContainerHeightConstraint.constant = newValue + safeAreaBottom
183183
}
184184
}
185-
186-
public override func viewSafeAreaInsetsDidChange() {
187-
if #available(iOS 11.0, *) {
188-
super.viewSafeAreaInsetsDidChange()
189-
tabBarHeight = buttonsContainerHeightConstraintInitialConstant
190-
} else {
191-
// Fallback on earlier versions
192-
}
193-
}
194185

195186
/// If you are setting a text for each menu using the function `setTitle(_:_:)`, you can decide how the text will be presented. When the value of this variable is false, then all titles will be visable. However if it is true, then only the title of the selected index is visale.
196187
open var onlyShowTextForSelectedButtons: Bool = false{
@@ -205,6 +196,12 @@ public class AZTabBarController: UIViewController {
205196
updateInterfaceIfNeeded()
206197
}
207198
}
199+
200+
/// Returns the current controller if exists.
201+
public var currentTab: UIViewController? {
202+
if selectedIndex >= 0,selectedIndex < tabCount, let controller = controllers[selectedIndex] { return controller }
203+
return nil
204+
}
208205

209206
/// The duration that is needed to invoke a long click.
210207
open var longClickTriggerDuration: TimeInterval = 0.5
@@ -437,6 +434,13 @@ public class AZTabBarController: UIViewController {
437434
let selectedButtonX: CGFloat = self.buttons[self.selectedIndex].frame.origin.x
438435
self.selectionIndicatorLeadingConstraint.constant = selectedButtonX
439436
}
437+
438+
public override func viewSafeAreaInsetsDidChange() {
439+
if #available(iOS 11.0, *) {
440+
super.viewSafeAreaInsetsDidChange()
441+
tabBarHeight = buttonsContainerHeightConstraintInitialConstant
442+
}
443+
}
440444

441445
/*
442446
* MARK: - AZTabBarController

0 commit comments

Comments
 (0)