I am getting data from JSON and it changes for each view so I need the labels to change their height depending on their content and also the rest of labels and buttons should move down. I am using sizeToFit
but anything else moves and when I scroll it loses its height and goes to 1 line again. My labels have 0 lines in storyboard.
@IBOutlet weak var titulares: UILabel!
@IBOutlet weak var scroller: UIScrollView!
@IBOutlet weak var imagen: UIImageView!
@IBOutlet weak var estilo: UILabel!
@IBOutlet weak var historia: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// I get JSON Data
self.historia.sizeToFit()
self.titulares.sizeToFit()
self.estilo.sizeToFit()
Use autolayout from the storyboard, press on a label and then in the right bottom side of the screen, you have the "Add new constrains" button. Use it to set a spacing from a view to it's neighbors
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.