Is there a support for AutoLayout in Swift Playgrounds on iOS10?

Hey everybody,


Does anybody know if I can use AutoLayout in Playgrounds or do I have to set view's frame manually? I've tried many things but can't make constraints work. I'm setting up constraints in viewDidLoad() but in viewWillAppear() all views have zero rect frames.

Thanks in advance

--

Patryk

Actually, it does work. I just ran into the exact same issue. Fix was easy though. You have to remember to explicitly set the following...

Code Block
view.translatesAutoresizingMaskIntoConstraints = false


This is because by default, the system will create constraints that match the frame, and *that* is what you're fighting with, not the playground itself.

That said, remember, if you are viewing a view alone (i.e. not in a UIViewController) technically you can only set the width and height as the position will always be top-centered of the preview area. If you want to be able to move your views anywhere, create a 'parent' view representing your screen or whatever, then place your views within that.
Is there a support for AutoLayout in Swift Playgrounds on iOS10?
 
 
Q