How to make a Storyboard scene responsive?

Xcode 7 allows you to add a view to the dock. However, the documentation does not indicate how this scene can be adaptive, so it changes its form factor depending on the size class of your device. The submission does not apply to any supervision, so there is no way to limit it to viewing.

How do you pretend to dock in a scene to be adaptive?

+6
source share
2 answers

Create an output in the code and add restrictions programmatically. For instance:

let margins = self.view.layoutMarginsGuide yourView.translatesAutoresizingMaskIntoConstraints = false yourView.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true yourView.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true yourView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor, constant: 20.0).isActive = true yourView.heightAnchor.constraint(equalToConstant: 260.0).isActive = true 
0
source

I would like to add to another answer of David.

A view does not apply to any supervision, so there is no way to limit it to viewing.

Yes there is!

 view.addSubview(yourSceneDockView) // or view.insertSubview(yourSceneDockView, at: 1) 

Only then can restrictions be applied to adapt the view.

0
source

All Articles