当我导航到某个 View Controller 时,我想要一个从底部开始的 View ,其中包含如下选项......
EDIT 1
我尝试按照链接中的建议使用 TableView 而不是 Collection View 来实现。这就是我所拥有的......
向下拖动 View 会给我这个 View ......
但是我来到 View 中,我不希望向上滑动的 View 覆盖 View 的整个长度,但它的大小应该只与第一个屏幕截图中给出的大小相同。我怎样才能实现这一目标..?
最佳答案
假设您使用的是我在评论中发布的同一个 github 项目。
首先删除垃圾:文件 -> TDStickyView
销售点
@IBOutlet weak var viewLeft: UIView! @IBOutlet weak var viewRight: UIView! private var angel : CGFloat = 0
来自
func viewSetup
: : // DELETE THESE 2 LINES AND THESE FUNC TOO. self.setCursors() self.rotateView(addAngel: 0)
来自
handleGesture
if aNewOrigin.y <= 60 { self.rotateView(addAngel: .pi/8) } else if aNewOrigin.y >= 60 && aNewOrigin.y < self.frame.height - 100 { self.rotateView(addAngel: 0) } else { self.rotateView(addAngel: -.pi/8) }
现在为cursorView添加约束,
- 对于左光标
- 对于右光标
现在项目已经稳定了,我们来谈谈您的需求。
- 在初始化时更改 tableView 的大小。
在viewSetup
中更改
//topMostY = UIApplication.shared.statusBarFrame.height
topMostY = parentVC.view.center.y
// It is the top most Y position of tableview and it can't go above it. Change it according to your requirement.
- 完全隐藏 TableView。
在handleGesture
中更改
else if sender.state == .ended {
self.panGestureColView.isEnabled = false
if velocity.y > 0 {
// go down
// UIView.animate(withDuration: 0.3) {
// self.frame = CGRect(origin: CGPoint(x: 0, y: self.parentFrame.size.height - self.bottomMostY), size: self.frame.size)
// }
// Change above commented UIView.animate with below UIView.animate
UIView.animate(withDuration: 0.3, animations: {
self.frame = CGRect(origin: CGPoint(x: 0, y: self.parentFrame.size.height), size: self.frame.size)
}) { (isFin) in
self.removeFromSuperview()
}
}
else if velocity.y < 0 {
// go up
UIView.animate(withDuration: 0.3) {
self.frame = CGRect(origin: CGPoint(x: 0, y: self.topMostY), size: self.frame.size)
}
}
}
仅此而已。
关于ios - 显示带有选项的底部 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55313819/