I'm learning AutoLayout's Visual Format Language (VFL) and trying to construct a view that has two elements:
- UITextView about 20 points from the top and should fill-up most of the vertical space available on an iPhone
- UIButton that needs to sit below the UITextView, without any padding between the two. The button bottom should be 20 points from the bottom of the parent view.
I thought that the following would do the trick.
let verticalBindings = ["textView": self.textView, "button": self.button]
let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat(
"V:|-20-[textView][button]-20-|",
options: NSLayoutFormatOptions.AlignAllLeft,
metrics:nil,
views:verticalBindings)
self.view.addConstraints(verticalConstraints)
However, when I run, the UITextView is not visible and something within how I'm choosing to layout the elements is obscuring it. How do you layout the elements such that they're vertically stacked on top of each other?
I'm also not sure how to set the size of the textView such that it should be whatever vertical space available after subtracting from the padding at the top and bottom and the height of the button.
I would prefer to use the VFL to describe this layout.