从底部显示带有选项的视图 [英] Show view from bottom with options
问题描述
当我导航到某个ViewController时,我希望从底部查看带有这样的选项的视图...
When I navigate to a certain viewcontroller, I want a view from bottom with options like so...
我怎么有这样的看法...?
How can I have such a view...?
编辑1
我尝试使用表视图而不是集合视图来实现链接中建议的功能.这就是我所拥有的...
I have tried to achieve as suggested in the link using a tableview instead of collection view. And this is what I have...
并向下拖动视图可得到此视图...
And dragging down the view gives me this view...
但是我进入视图,我不希望向上滑动视图覆盖视图的整个长度,但是它的大小应该与第一个屏幕截图中给出的大小相同.我该如何实现呢??
But I come to the view, I don't want the slide up view to cover the entire length of the view, but it should only be of the same size as given in the 1st screenshot. How can I achieve that..?
推荐答案
假设您使用的是我在评论中发布的同一个github项目.
Assuming you are using same github project that I posted in comment.
-
奥特莱斯
Outlets
@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添加约束
- 对于左光标
- 对于右光标
- 在init上更改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)
}
}
}
仅此而已.
That's all.
这篇关于从底部显示带有选项的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!