简体   繁体   中英

Add half size view using storyboard in swift

I'd like to add a half size view on a parent view. When I push a button on the parent view, the half size view appear, then I push the rest of the screen(the area half size view doesn't cover), the half size view disappear. When the half size view appear, I don't want let the parent view scroll.

I've written the following code, however the parent view scrolls in this case. Please tell me how I should do.

func tapPickView(){
var storyboard : UIStoryboard = UIStoryboard(name: "Answer", bundle: nil)

var controller : AnswerViewController = storyboard.instantiateViewControllerWithIdentifier("AnswerVC") as! AnswerViewController
controller.view.backgroundColor = UIColor.clearColor()
var answerView = controller.view
self.view.addSubview(answerView)
}

You may want to add a full size overlay UIButton with transparent background image under your half size view and above your parent view. The UIButton will fire an action to dismiss the half size view.

The overlay UIButton can take over all the user interaction events sent to the parent view.

通过使用以下代码,我得到了想要的!

tableView.scrollEnabled = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM