Closed sasojadrovski closed 6 years ago
I have similar issue while trying to hide using Tap Gesture.. I tried
I tried calling tabBarController!.tabBar.hidden = true in viewDidLoad() and it hides the TabBar. However, I tried to set tap gesture and hide the bar on Tap. The parent viewController that has ScrollView inside it with subview (that is connected with IBOutlet as myView)
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
myView.addGestureRecognizer(tap)
}
func handleTap(sender: UITapGestureRecognizer? = nil) {
print("A") // logs successfully
if TabBarHidden == false {
print("B") // logs successfully
//I tried:
tabBarController?.tabBar.hidden = true
// I also tried
tabBarController?.tabBar.alpha = 0
tabBarController?.tabBar.frame.origin.x += 50
hidesBottomBarWhenPushed = true
} else {
...
TabBarHidden = false
}
}
Update: I also tried this but I couldn't make it work also.
class ViewController: UIViewController {
var tabBarHidden: Bool = false {
didSet {
tabBarController?.tabBar.hidden = tabBarHidden
}
}
override func viewDidLoad() {
super.viewDidLoad()
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapGestureRecognized(_:)))
view.addGestureRecognizer(tapGestureRecognizer)
}
func tapGestureRecognized(sender: UITapGestureRecognizer) {
tabBarHidden = !tabBarHidden
}
}
Similarly, if I call tabBarHidden = !tabBarHidden
inside viewDidLoad()
, it surprisingly works!
What may be the problem?
Hey @ober01,
Could you please take a look at this one?
Thanks in advance!
Hi @sasojadrovski To resolve it : you can make your UINavigationController -> UITabBarController -> Your VCs. But it is not a good way. I think the good way is put the container views into the TabBarItem , not into the UITabBarController.view.
I have similar issue and solved by this: https://github.com/Ramotion/animated-tab-bar/issues/84
@Geeerry It not work like system hidden effect when I create like this: UITabBarController -> 4 UINavigationController s. Whay not take the containers into tabbar.
@eggswift 看你也是北京的就用中文吧👻 我有点儿没明白你的“UITabBarController -> 4 UINavigationController s.”的意思
对这样是会异常 这个隐藏方法需要用在你说的NavigationController的nextViewController(就是你要push的那个ViewController)的情况下。 直接调用系统的hidesBottomBarWhenPushed用在这个project的TabBar里有很多问题...
@Geeerry
As far as I understand, you used this to resolve the issue?
let animatedTabBar = self.tabBarController as! RAMAnimatedTabBarController animatedTabBar.animationTabBarHidden(true)
I tried it too, and it's hiding the TabBar (and I need to hide the TabBarItems separately). However, I couldn't figure out how to bring it back...
For instance, I have a hierarchy like..
- TabBarController
-- NavBarController
--- ViewController
---- SubViewController (navigated from NavBarItem)
At this point, when I hit SubViewController, I want to hide the TabBar; and on ViewController, show the TabBar..
I tried your approach (the code above).. It hides the TabBar only, however not the TabBarItems. I thought I should hide the TabBarItems individually.. Then another problem rises.. When I hit 'Back' on SubViewController's NavBar, I couldn't make it work to inverse the 'hiding process' on ViewController.. I couldn't figure out where to put animatedTabBar.animationTabBarHidden(false)
for example, and bring it back for the ViewController...
Did anyone figured out how to workaround this issue?
@sentiasa Hi! It's very easy to solve this issue by using this:
override func viewDidLoad() {
// Hide TabBar
let animatedTabBar = self.tabBarController as! RAMAnimatedTabBarController
animatedTabBar.animationTabBarHidden(true)
}
override func viewWillDisappear(animated: Bool) {
// Show TabBar
let animatedTabBar = self.tabBarController as! RAMAnimatedTabBarController
animatedTabBar.animationTabBarHidden(false)
}
@sentiasa
Put that to the SubViewController
😊
@Geeerry Thanks a lot.. Even though the animated hide doesn't work for now, I can use that for workaround. Cheers :)
I have the same issue but I'm using HidingNavigationBar Library to hide my tab bar whit this code:
if let tabBar = navigationController?.tabBarController?.tabBar{
hidingNavBarManager?.manageBottomBar(tabBar)
tabBar.barTintColor = UIColor.blackColor()
}
I was trying something like this, but it doesn't work:
if let tabBar = navigationController?.tabBarController as? RAMAnimatedTabBarController {
hidingNavBarManager?.manageBottomBar(tabBar.tabBar)
tabBar.tabBar.barTintColor = UIColor.blackColor()
}
Here example in GIF
Someone knows how can I integrate the two libraries? Thanks and maybe it can help for someone.
@dasoga I wanted to accomplish same effect. I ended up hiding NavBar manually and I couldn't find any way for hiding AnimatedTabBar with animation so I left it there. I see you got closer with HidingNavigationBar library.
If you find any workaround, please let me know here too.
Hi @sentiasa I just needed to implement bounce animation for my app, so I did it manually with the tab bar delegate method:
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
var secondItemImageView: UIImageView!
let secondItemView = self.tabBar.subviews[item.tag]
secondItemImageView = secondItemView.subviews.first as! UIImageView
secondItemImageView.contentMode = .Center
secondItemImageView.transform = CGAffineTransformIdentity
UIView.animateWithDuration(0.7, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 1, options: .CurveEaseInOut, animations: { () -> Void in
let bounceAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
bounceAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
bounceAnimation.duration = NSTimeInterval(0.5)
bounceAnimation.calculationMode = kCAAnimationCubic
secondItemImageView.layer.addAnimation(bounceAnimation, forKey: nil)
}, completion: nil)
}
Hope can help you!
@sasojadrovski check my question/answer: https://github.com/Ramotion/animated-tab-bar/issues/109 I got it working by setting hidesBottomBarWhenPushed to true in both VC's and also adding animationTabBarHidden(false) in VC1 and animationTabBarHidden(true) in VC2
@dasoga I ended up doing the same thing:
var secondItemImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
let secondItemView = self.tabBar.subviews[1]
self.secondItemImageView = secondItemView.subviews.first as! UIImageView
self.secondItemImageView.contentMode = .Center
}
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if item.tag == 1{
self.secondItemImageView.transform = CGAffineTransformMakeScale(0.1, 0.1)
UIView.animateWithDuration(2.0,
delay: 0,
usingSpringWithDamping: 0.2,
initialSpringVelocity: 6.0,
options: UIViewAnimationOptions.AllowUserInteraction,
animations: {
self.secondItemImageView.transform = CGAffineTransformIdentity
}, completion: nil)
}
}
viewContainer should add in tabbar not tabbar view controller's view
@hologerry It works~~Thanks
@dasoga I have the same issue. Not solved in latest version.
My solutions is: _rootTabBar is my RAMAnimatedTabBarController
func hideTabbar() {
for item in (_rootTabBar?.view.subviews)! {
print("item class: \(item.className)")
if item.className == "UIView" {
item.isHidden = true
}
}
_rootTabBar?.tabBar.isHidden = true
}
func showTabbar() {
for item in (_rootTabBar?.view.subviews)! {
print("item class: \(item.className)")
if item.className == "UIView" {
item.isHidden = false
}
}
_rootTabBar?.tabBar.isHidden = false
}
className is one of my extensions
extension NSObject {
var className: String {
return String(describing: type(of: self))
}
class var className: String {
return String(describing: self)
}
}
wow, they still didnt fix it since 2016!!
@omarshamali try ESTabBarController
@eggswift its a nice library, gonna try it now! thanks mate.
Duplicate of #144
Hey guys,
First of all let me thank you for this amazing library! It really gives the applications a new dimension :)
I have come across a major issue when trying to hide the TabBar while pushing another ViewController to the UINavigation stack. If the property hidesBottomBarWhenPushed is set on the ViewController that is about to be pushed, the TabBar behaves very strange...
I have also tried using the animationTabBarHidden(true) method, but this requires that the hidesBottomBarWhenPushed property is not set. But if this property is not set, then the TabBar hides, but leaves an empty view at the bottom of the screen and when you pop from the pushed ViewController, the TabBar does not appear. Of course, you can call the animationTabBarHidden(false) method again on viewWillAppear: but there is a delay and does not look good.
Please investigate this issue or if it is not an issue, please provide some guidelines on how to reach the expected behaviour.
Cheers, Sasho