ios 底部弹窗滑动_如何添加底部向上滑动查看iOS版

Hello I am developing app which has UI like below images..

I am not able to understand how to create bottom swipe up view.

I have tried swipe up gesture on bottom view to open it.

But I want to open bottom view with finger (means slow upward drag of view should reveal bottom view slowly)

I am using auto layout and storyboard. How do I achieve this ?

I have searched a lot and I got this https://github.com/crocodella/PullableView but I am not able to add this view with storyboard and auto layout.

解决方案

I Just want say before solution is that this is not gonna be drag like effect for that you need to use gesture...but It gives you similar effect if you strongly need it with button click.. I think its not what you want but this give you an option if you want

For drag bottom view to top,you shold use gesture and this may help you

or this

You got the similar effect using constant property of constraints..like Give the height constraint to bottom view and use constant property on click event to swipe up and down.

Still confused!!! Here is the solution

UI setup

Constraints Setup

After that You just need to make some outlets and click event of button...

make an outlet of height constraint of bottom view

make an outlet of button to change its title to up/down

make and click event of button

After this procedure you need to code on button action, So here is that code

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()

})

}

}

}

and the output of this work would be

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值