gpt4 book ai didi

ios - UIScrollView动态状态栏

转载 作者:搜寻专家 更新时间:2023-10-31 22:47:39 25 4
gpt4 key购买 nike

我有一个包含 2 个 View 的 ScrollView :一个 UIImagePicker(Snapchat 风格的相机 View )和一个 UITableView。

ScrollView 位于主视图 Controller 推送到的导航 Controller 内。我希望状态栏及其上的所有内容(时间、电池、wifi 等)隐藏在相机 View 中,但是当您向右滚动到 tableView 时,状态栏内容会重新显示,无论它们是否做了一些滚动时的一种很酷的拉伸(stretch)动画(弄清楚这一点会很棒)或任何其他可能的解决方案。

希望我的措辞足以让您理解。

最佳答案

我找到的解决方案(更多的解决方法)声明一个名为 hidden 的 bool 值。然后我覆盖了这些方法:

func scrollViewDidScroll(scrollView: UIScrollView){
let xOffset = scrollView.contentOffset.x;


if(xOffset > scrollView.contentSize.width/4)
{
if hidden == true {
print("\nShow status bar\n")

hidden = false
UIView.animateWithDuration(0.3, animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
}
} else
{
print("\nHide Status Bar\n")

hidden = true
UIView.animateWithDuration(0.2, animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
}
}

override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
if hidden == false {
return UIStatusBarAnimation.Fade
} else {
return UIStatusBarAnimation.Slide
}
}

override func prefersStatusBarHidden() -> Bool {
print("\nstatus Bar Changed to hidden = \(hidden)\n")
return hidden
}

它会在您至少滚动到一半时淡入状态栏,并在您再次返回一半时将状态栏向上滑动。

关于ios - UIScrollView动态状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34387833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com