将视图显示为另一个视图前方的向上滑动手势

你好,我正在开发有像下面的图像UI的应用程序..

我无法理解如何创build底部刷卡视图。 我已经尝试向上滑动底部视图的手势来打开它。 但是我想用手指打开底部视图(意味着缓慢的向上拖动视图应该缓慢地显示底部视图)

我正在使用自动布局和故事板。 我如何做到这一点?

我搜查了很多,我有这个https://github.com/crocodella/PullableView,但我不能添加这个视图故事板和自动布局。

在这里输入图像说明

在这里输入图像说明

我只想说,解决之前,这是不会像拖动效果,因为你需要使用手势…但它会给你类似的效果,如果你强烈需要它与button点击..我认为它不是你想要的,但这给你一个选项,如果你想

对于拖动底部视图到顶部,你可以使用手势,这可能会帮助你

在iOS 5中向下拖动UIView

或这个

http://www.jondev.net/articles/Dragging_View_with_Finger_(iPhone)

您可以使用约束的constant属性获得类似的效果。如给底部视图的高度约束和在点击事件上使用常量属性来上下滑动。

仍然困惑! 这是解决scheme

UI设置

在这里输入图像说明

约束设置

在这里输入图像说明

之后,你只需要做一些sockets,点击button事件…

  • 做出底视高度约束的出口
  • 使button的出口改变其标题上/下
  • 制作并点击button的事件

在这个过程之后,你需要在button动作上编码,所以这里是这个代码

 class ViewController: UIViewController { // Button outlet @IBOutlet weak var btnUp: UIButton! // Height Constraint outlet @IBOutlet weak var constHeightBottomView: NSLayoutConstraint! // Boolean property to handle click var clicked = true override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func btnUpClicked(sender: UIButton) { if clicked{ self.clicked = !clicked UIView.animateWithDuration(0.2, animations: { self.btnUp.setTitle("Down", forState: .Normal) self.constHeightBottomView.constant = 200 self.view.layoutIfNeeded() }) } else{ self.clicked = true UIView.animateWithDuration(0.2, animations: { self.btnUp.setTitle("Up", forState: .Normal) self.constHeightBottomView.constant = 0 self.view.layoutIfNeeded() }) } } } 

而这项工作的成果将是

在这里输入图像说明