antiguab / BATabBarController

A TabBarController with a unique animation for selection
https://antiguab.github.io/batabbarcontroller/
MIT License
1.06k stars 131 forks source link

how to use hidesBottomBarWhenPushed #31

Closed tarek903 closed 5 years ago

tarek903 commented 6 years ago

hidesBottomBarWhenPushed is a property of a UIViewController how to use with BATabBarController

for example :


 override func viewDidLayoutSubviews() {

        if(self.firstTime){

            var libraryTabBarItem : BATabBarItem!
            var createTabBarItem : BATabBarItem!
            var getInspiredTabBarItem : BATabBarItem!
            var activitiesTabBarItem : BATabBarItem!
            var myProfileTabBarItem : BATabBarItem!

            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            // LIBRARY
            let LibraryNC = storyboard.instantiateViewController(withIdentifier: "libraryNavigationController") as! UINavigationController
            // CREATE
            let CreateNC = storyboard.instantiateViewController(withIdentifier: "createNavigationController") as! UINavigationController           
            // GET INSPIRED
            let GetInspiredVC = storyboard.instantiateViewController(withIdentifier: "GetInspiredViewController") as! GetInspiredViewController
            // ACTIVITIES
            let ActivitiesVC = storyboard.instantiateViewController(withIdentifier: "ActivitiesViewController") as! ActivitiesViewController
            // MY PROFILE
            let MyProfileVC = storyboard.instantiateViewController(withIdentifier: "MyProfileViewController") as! MyProfileViewController

            var attrs = [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 11.0) , NSAttributedStringKey.foregroundColor : UIColor.white]

            let LibraryString = NSMutableAttributedString(string:"LIBRARY", attributes:attrs)
            let CreateString = NSMutableAttributedString(string:"CREATE", attributes:attrs)
            let GetInspiredString = NSMutableAttributedString(string:"GETINSPIRED", attributes:attrs)
            let ActivitiesString = NSMutableAttributedString(string:"ACTIVITIES", attributes:attrs)
            let MyProfileString = NSMutableAttributedString(string:"MYPROFILE", attributes:attrs)

            libraryTabBarItem = BATabBarItem(image: UIImage(named:"ic_photo_library_white_36pt"), selectedImage: UIImage(named:"ic_photo_library_white_36pt")?.maskWithColor(color: UIColor.red), title: LibraryString)
            createTabBarItem = BATabBarItem(image: UIImage(named:"ic_mode_edit_white_36pt"), selectedImage: UIImage(named:"ic_mode_edit_white_36pt")?.maskWithColor(color: UIColor.red), title: CreateString)
            getInspiredTabBarItem = BATabBarItem(image: UIImage(named:"ic_youtube_searched_for_white_36pt"), selectedImage: UIImage(named:"ic_youtube_searched_for_white_36pt")?.maskWithColor(color: UIColor.red), title: GetInspiredString)
            activitiesTabBarItem = BATabBarItem(image: UIImage(named:"ic_mail_white_36pt"), selectedImage: UIImage(named:"ic_mail_white_36pt")?.maskWithColor(color: UIColor.red), title: ActivitiesString)
            myProfileTabBarItem = BATabBarItem(image: UIImage(named:"ic_person_outline_white_36pt"), selectedImage: UIImage(named:"ic_person_outline_white_36pt")?.maskWithColor(color: UIColor.red), title: MyProfileString)

            baTabController = BATabBarController()
            baTabController.viewControllers = [LibraryNC,CreateNC,GetInspiredVC,ActivitiesVC,MyProfileVC]
            baTabController.tabBarItems = [libraryTabBarItem,createTabBarItem,getInspiredTabBarItem,activitiesTabBarItem,myProfileTabBarItem]

            self.baTabController.delegate = self;
           // self.baTabController.hidesBottomBarWhenPushed = true
            self.view.addSubview(self.baTabController.view)
            self.firstTime = false;
}

now if LibraryNC or CreateNC pushes a viewController i want the tabs to be hidden

thanks in advance

Easyzhan commented 6 years ago

same as you, self.vc.hidesBottomBarWhenPushed = YES; this line always hiden.