0

Using storyboard, I am trying to put a UILabel below UITextView. Content of UITextView can grow based on user input. I want my UILabel to reposition its Y value based on UITextView contents. I've tried fixing vertical spacing between UITextView and UILabel but that is not helping.

What else I shall be doing to crack this?

Abhinav
  • 37,684
  • 43
  • 191
  • 309
  • you can change your label position in delegate of textView : changeCharactersInRange: – Divyanshu Sharma Nov 20 '15 at 06:45
  • I want to do it via storyboard only. Have done it through code. Wanted to explore auto layout and storyboard options. – Abhinav Nov 20 '15 at 06:47
  • If you [configure your text view to not scroll vertically](http://stackoverflow.com/a/21287306/77567), it will be able to resize itself to fit its text, and you should be able to constrain your label to the bottom of the text view. – rob mayoff Nov 21 '15 at 00:36

1 Answers1

0

You should use constraints explicitly. The label in particular must have the constraint "top space to Textview" set to N points. Then set an outlet in your view controller from the constraint "top space to Textview" and change that constraint to resize uilabel Y position.

@IBOutlet weak var labelYConstraint: NSLayoutConstraint!

func changeLabelPosition(sender: AnyObject) {

    labelYConstraint.constant = newY
}

Let me know if you need more details

Divyanshu Sharma
  • 551
  • 2
  • 12