When I navigate to a certain viewcontroller, I want a view from bottom with options like so...
How can I have such a view...?
EDIT 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..?
Assuming you are using same github project that I posted in comment.
TDStickyView
Outlets
@IBOutlet weak var viewLeft: UIView!
@IBOutlet weak var viewRight: UIView!
private var angel : CGFloat = 0
From func viewSetup
:
:
// DELETE THESE 2 LINES AND THESE FUNC TOO.
self.setCursors()
self.rotateView(addAngel: 0)
From 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)
}
In viewSetup
change
//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.
In handleGesture
change
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.