吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1208|回复: 2
收起左侧

[其他原创] [ios]tabbar页面切换隐藏技巧(连载6)

[复制链接]
debug_cat 发表于 2021-3-11 10:40
先看看我们效果吧~
Images_1615430224260.GIF

把之前的几个学习的串联一起了。

这一次我们整合之前做的效果

我们写了类似掘金的底部tab。和前面的数据获取,页面跳转。

现在我们把全部整合在一起,看看效果如何。

这里面,包含了一个知识,页面跳转的时候,底部tab是不会隐藏的。

现在封装好,如何隐藏底部的tab。和返回的时候,正常展示。

替换基类:

    func initTab() {
        let homeVC = CustomNavigationControllerViewController(rootViewController: WxListController())
        homeVC.tabBarItem.title = "首页"
        homeVC.tabBarItem.image = UIImage(named: "tab_home_normal")

        let activityVC = CustomNavigationControllerViewController(rootViewController: ActivityViewController())
        activityVC.tabBarItem.title = "沸点"
        activityVC.tabBarItem.image = UIImage(named: "tab_activity")

        let findVC = CustomNavigationControllerViewController(rootViewController: FindViewController())
        findVC.tabBarItem.title = "发现"
        findVC.tabBarItem.image = UIImage(named: "tab_find_normal")

        let ceVC = CustomNavigationControllerViewController(rootViewController: CeViewController())
        ceVC.tabBarItem.title = "小册"
        ceVC.tabBarItem.image = UIImage(named: "tab_xiaoce_normal")

        let meVC = CustomNavigationControllerViewController(rootViewController: MeViewController())
        meVC.tabBarItem.title = "我的"
        meVC.tabBarItem.image = UIImage(named: "tab_profile_normal")

        viewControllers = [homeVC, activityVC, findVC, ceVC, meVC]
        setTabBarItemAttributes(fontName: "Courier", fontSize: 13, normalColor: ColorUtils.parser("#969695")!, selectedColor: ColorUtils.parser("#027AFF")!, bgColor: UIColor.white)
    }

基类代码:

class CustomNavigationControllerViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        //当控制器数量大于0,也就是不是第一个页面跳转了.
        if viewControllers.count > 0 {
            //隐藏底部的bar
            viewController.hidesBottomBarWhenPushed = true
        }
        //在push之后,增加上面的逻辑,通用处理bar显示的问题
        super.pushViewController(viewController, animated: animated)
    }

}

这就是处理底部tab隐藏显示的逻辑了。

整个小demo的效果图就是这样了。

接下来的计划:

1:写一个简单版本购物app

2:前期需要准备的是后台服务,这个服务已经搭建起来了。现在我还需要对服务进行调整和熟悉。

3:网络的数据是我自己服务器的,所以变动的情况是我自己控制

4:由于是个人业余学习的项目,所以更新可能比较慢点,但是我会满满更新开源出来的

5:作为萌新,我没有系统的学习过这个开发,很多东西都是需要用到 -> 去查。需求驱动式。

6:希望自己可以坚持下去啦,后面会把整个系列的文章整理好,然后放到个人博客哪里去。

7:希望朋友们多多支持

代码地址:

https://github.com/cat13954/IOSUiTableViewSample

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
mo211683 + 1 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

1096315079a 发表于 2021-3-11 10:43
写的好,必须支持一波
 楼主| debug_cat 发表于 2021-3-11 10:58
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-4 15:02

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表