Closed KittenYang closed 8 years ago
I'm having the same problem. I can hide the bar itself, but the icons stay. I've even tried to individually hide and disable the icons, but I was unsuccessful. I really want to use it, but I can't until this is solved.
@megatyx Lastly ,I give up and use the original tabbar. Sigh~
Create a new class import UIKit
extension RAMAnimatedTabBarController:UINavigationControllerDelegate{ func hideTabBar(flag:Bool) { let atc = self let icons = atc.iconsView
if (flag == true ) {
for icon in icons {
icon.icon.superview?.hidden = true
}
atc.tabBar.hidden = true
} else {
atc.tabBar.hidden = false
for icon in icons {
if let sup = icon.icon.superview{
sup.hidden = false
sup.superview?.bringSubviewToFront(sup)
}
}
}
}
func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool){
hideTabBar(viewController.hidesBottomBarWhenPushed)
}
}
in RAMAnimatedTabBarController.swift viewDidLoad let conls = (self.viewControllers as? [UIViewController])?.filter({$0 is UINavigationController}) ?? [] for ctl in conls{ (ctl as! UINavigationController).delegate = self } Because I was so mixed before the OC will also cover the situation tabbar icon So you must remember to call self.hidesBottomBarWhenPushed = YES you want to hide tabbar of oc interface ; Remember not generate Bridging-Header directly call self.hidesBottomBarWhenPushed = YES;
func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
hideTabBar(viewController.hidesBottomBarWhenPushed)
}
self.tabBarController.tabBar.hidden = YES;
self.hidesBottomBarWhenPushed = YES;
Join these can be synchronized to hide tabbar not have to hide when we jump
Thanks @LiuHengChina , very well done :)
Hello guys, I'm having similar problems hiding TabBar. This solution works for me too, but I'm just wondering is it possible to add some animation when BottomBarr hides?
I also tried to hide TabBar on button click (calling setTabBarVisible(!tabBarIsVisible(), animated: true)) with these functions, but that doesn't work like with regular UITabBarController.
func setTabBarVisible(visible: Bool, animated: Bool){
// bail if the current state matches the desired state
if (tabBarIsVisible() == visible) { return }
// get a frame calculation ready
let frame = self.tabBarController?.tabBar.frame
let height = frame?.size.height
let offsetY = (visible ? -height! : height)
// zero duration means no animation
let duration:NSTimeInterval = (animated ? 0.3 : 0.0)
// animate the tabBar
if frame != nil {
UIView.animateWithDuration(duration) {
self.parentViewController?.tabBarController?.tabBar.frame = CGRectOffset(frame!, 0, offsetY!)
return
}
}
}
func tabBarIsVisible() ->Bool {
return self.parentViewController?.tabBarController?.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame)
}
Can we disable gesture on the tab item to so that we would have a complete full screen view with no impact of TabBarController
The proposed solution also doesn't work with interactionTransitions
on UINavigationController
's swipe back feature. It will instantly pop them up above the from
controller. Is there anyway around this?
@ryancstack so i just give it up.but honestly it's a really dope animation:P
@KittenYang you went back to UITabBarController
?
@ryancstack yep.
I then use model presentation instead :|
i use tabbar' s subviews to get the show Image and label, not to create the constains view if you @LiuHengChina ' methods, when you push a view controller , the constains view will disappear in an instant, we need a duration animation. the code is:
func createCustomIcons() {
guard (tabBar.items != nil) else {
fatalError("tabBar.items was nil")
}
for item in tabBar.items! as! [TmAnimationTabBarItem] {
assert(item.image != nil, "add image icon in uitabbaritem")
var index = 0
for tabBarButton in tabBar.subviews {
if let icon = tabBarButton.subviews.first as? UIImageView, let label = tabBarButton.subviews.last as? UILabel {
iconsView.append((icon: icon, textLabel: label))
}
let tapGesture = UITapGestureRecognizer(target: self, action: "tapHandler:")
tabBarButton.addGestureRecognizer(tapGesture)
tabBarButton.tag = index
index++
}
}
}
and in itemAnimations, use
textLabel.tintColor = textSelectedColor
icon.superview?.superview?.tintColor = iconSelectedColor
not
textLabel.textColor = defaultTextColor
if let iconImage = icon.image {
let renderImage = iconImage.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
icon.image = renderImage
icon.tintColor = defaultTextColor
}
it' s ok to work
added method func animationTabBarHidden(isHidden:Bool) I hope this helps
How i can disable tabbar item?
@mhtranbn animationTabBarHidden(true)
Thanks @satyamub When the first launch tabbar. I want change color of tabbar item. not hiddent. https://lh3.googleusercontent.com/stTiAxzpyFVyJgyqMAzh59zTRUJIiUl8UsAHpNOxlTfVVHvj-lSTq1Uy1y2ZbhpwPVF1CIfr5c2ZrwaeNtrQ1JmSK1Rwo55K_UvPr2InfHvgb3o9sxKdhxaKWAFxPXM477w5AxtOBs-Gl7ZWeX2S2feDkwK1XESeDwkoUzfWSZtf0HVh60CinDodJnH6HglHkmieYH3NU0tZIxtECU-tS-0TQS8RLkhn-uUCFONw-E2GXV9j4415XB4eKTtCtr9jVMGeKFnMZzD44jjg4VcwDD5b0L7AAN9T6hTVHzCWISPB9cYbaiVQ7iuBSZtJN0PbEBILo0G-QKDzs6KX-2QxIAUX7wxNWjsZjKUC-M-6EdvxrMjppLZmtlgbbdnPXIHgEg9kEuhIxBCkxW_mK051CNR5mbDEJIYC4JbG7Nub0oW2xtfhkMiWxl6wW_aA2iKfX9Y4jqfkGnet0O2qn2W6OF3e_kRBnJXiSybh-V2FfKRbSAzQr8YhUuM83SvkWWBLoMcoxKa-x5bEmFaAUP5LcemEBpwo9NRFhOFGkR-CmDczBAklvOv6j4CC7i9H7PyM_31evKMaQhZLqluv76ScZhlojZ2dHSUE=w151-h61-no
when executing animationTabBarHidden()true, it fails to add the tabbar.items to guard let item. Displays the error "add tabbar items"
When i change the tab bar selected index (click on button on uiviewcontroller screen not in tabbar) then page change but select icon not change in tab bar self.tabbarcontroller!.selectedIndex = 2
Nobody should use this library. Hiding the tab bar is basic functionality of the standard tab bar. This is just poor design. I am going to remove this library from my project. Just not worth it at all.
@hammadzz me too, spent much time for such poor library
Maybe it is not really a good code design, but I solved the hide problem like this:
let animatedTabBar = tabBarController as? RAMAnimatedTabBarController animatedTabBar?.animationTabBarHidden(true)
When I pushed from a VC to anothor VC,I want to hide the tabbar. So what I do first is set the "Hide Bottom Bar on Push" in the Storyboard ,the result is the tabbar is hidden indeed but the UITabbarItems are still.I also use UIVIew.animateWIthDurarion() to hide the tabbar but also failed.What can I do to hide the tabbar and the tabbaritem?