导航栏切换渐变方案的一些参考

iOS 判断界面消失或出现的时候是push进来还是pop出去

https://blog.csdn.net/modalyin/article/details/79374025

一个github

https://github.com/wangrui460/WRNavigationBar_swift

iOS透明导航栏的平滑过渡(进阶版)

https://www.jianshu.com/p/94910b42396c

导航栏的平滑显示和隐藏 - 个人页的自我修养(1)

https://www.jianshu.com/p/454b06590cf1

这个是已经过时的方法

https://github.com/ltebean/LTNavigationBar

Deprecated

This lib uses a hacky way to achieve the result, in the new iOS version, the structure of UINavigation is changed and this lib no longer works anymore, so please check these alternatives:

swift version

https://github.com/ltebean/LTNavigationBar/tree/swift3.0

我个人目前的用法:

class MYTableViewController: MainTableViewController {   
 var vcAplpa:CGFloat = 0.0
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem
        navBarTransparent()
        self.title = "哈哈哈哈"
        self.view.adaptScreenWidth(with: .all, exceptViews: nil)
        self.extendedLayoutIncludesOpaqueBars = true
    }
    
    override func scrollViewDidScroll(_ scrollView: UIScrollView) {
        var offY = scrollView.contentOffset.y
        if offY > 0 {
            if offY > 64 {
               offY = 64
            }
            let aphal =  offY / 64.0
            navBarChange(aphal)
            self.vcAplpa = aphal
        } else {
            navBarChange(0)
            self.vcAplpa = 0
        }
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        navBarChange(vcAplpa)
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        let viewControllers = self.navigationController?.viewControllers
        if let count = viewControllers?.count, count > 1 && viewControllers![count - 2] == self {
            // push
            print("push")
        } else {
           normalNavBar()
        }
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值