Skip to content

Commit

Permalink
Added currentTab
Browse files Browse the repository at this point in the history
  • Loading branch information
Minitour committed Oct 24, 2017
1 parent d9ad21d commit 3934625
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Sources/AZTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,6 @@ public class AZTabBarController: UIViewController {
self.buttonsContainerHeightConstraint.constant = newValue + safeAreaBottom
}
}

public override func viewSafeAreaInsetsDidChange() {
if #available(iOS 11.0, *) {
super.viewSafeAreaInsetsDidChange()
tabBarHeight = buttonsContainerHeightConstraintInitialConstant
} else {
// Fallback on earlier versions
}
}

/// 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.
open var onlyShowTextForSelectedButtons: Bool = false{
Expand All @@ -205,6 +196,12 @@ public class AZTabBarController: UIViewController {
updateInterfaceIfNeeded()
}
}

/// Returns the current controller if exists.
public var currentTab: UIViewController? {
if selectedIndex >= 0,selectedIndex < tabCount, let controller = controllers[selectedIndex] { return controller }
return nil
}

/// The duration that is needed to invoke a long click.
open var longClickTriggerDuration: TimeInterval = 0.5
Expand Down Expand Up @@ -437,6 +434,13 @@ public class AZTabBarController: UIViewController {
let selectedButtonX: CGFloat = self.buttons[self.selectedIndex].frame.origin.x
self.selectionIndicatorLeadingConstraint.constant = selectedButtonX
}

public override func viewSafeAreaInsetsDidChange() {
if #available(iOS 11.0, *) {
super.viewSafeAreaInsetsDidChange()
tabBarHeight = buttonsContainerHeightConstraintInitialConstant
}
}

/*
* MARK: - AZTabBarController
Expand Down

0 comments on commit 3934625

Please sign in to comment.