1

I'm building an app and it has a description of everyone on the roster section. The text seems to overrun the page and I do not know the code or way to make it fill programmatically.

I have tried changing the values on the line of code the UITextField is in.

 let descriptionM = UITextField(frame: CGRect(x: xPosition+15, y: 
 500, width: 300, height: 50))
        descriptionM.text = desc[i]
        descriptionM.textColor = UIColor.black
        descriptionM.backgroundColor = UIColor.clear
        descriptionM.contentMode = .scaleAspectFill

I wanted the text which is an array above, to fill the certain page on the scroll view instead it runs over the right side of the view with only the first line readable.

I have tried different values but non have worked.

  • Why you are using UITextField in order to fill text. If you don't want to edit the description you can simply add a UILabel and set number of lines to zero in order to be a multiline label. – Dimitrios Kalaitzidis May 22 '19 at 16:00

1 Answers1

0

I have tried changing the values on the line of code the UITextField is in.

You're using the wrong tool for the job. Text fields only ever handle one line, which is why there are no properties that let you set the number of lines.

I wanted the text which is an array above, to fill the certain page on the scroll view instead it runs over the right side of the view with only the first line readable.

Views that display text on multiple lines include UILabel and UITextView. UILabel is really meant for just a few lines or less, and it sounds like you may need many lines, so you should switch to UITextView. Or, if you're displaying a number of distinct items rather than paragraphs of text, you could use a UITableView where each cell displays a single item using a UILabel, UITextField, or UITextView. Table views are great for presenting arrays of data.

Caleb
  • 124,013
  • 19
  • 183
  • 272