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:
- https://github.com/andreamazz/AMScrollingNavbar
- https://github.com/DanisFabric/RainbowNavigation
- https://github.com/MoZhouqi/KMNavigationBarTransition
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()
}
}