AutoLayout Issue in Xcode11

Hi am new to ios development. Am using swift4 and xcode 11

I kept 4 labels inside scrollview and uiview and then set constraints for them.

I set Top,Leading, dynamic height and Trailing constraints for 4 labels which is inside uiview (which is inside scrollview)but all the labels appear in the top most area which is not visible and overlapping.

when the labels are kept without uiview and scroll view it runs perfectly.


Please help me to resolve this issue

have you tried just using a scrollview without the uiview?

yes…i tried30%20PM
but didnt work

it seems like its in the right space… try setting the constraints to safeview instead of uiview

its working . Am trying dynamic resizing of fonts (when font size changed in settings apps font size should change)

  1. i tried setting 4 labels to safe area(top,leading,trailing)[Its constraints are working but when font size increases labels overlapping]

  2. first label to safe area and other three labels from first ,second…lke that[ first label constraints work but other three labels goes up]

without this code its working fine (normally) but when i apply this code autolayout for labels did not set properly but working when i set constraints to safearea.

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var myScrollView: UIScrollView!
@IBOutlet weak var myView: UIView!
@IBOutlet weak var myLabel: UILabel!

@IBOutlet weak var firstLabel: UILabel!
    @IBOutlet weak var secondLabel: UILabel!
@IBOutlet weak var thirdLabel: UILabel!

override func viewDidLoad() {
    // Do any additional setup after loading the view.

    myLabel.text = "The traditional Christmas narrative, the Nativity of Jesus, delineated in the New Testament says that Jesus was born in Bethlehem, in accordance."
    firstLabel.text = "When Joseph and Mary arrived in the city, the inn had no room and so they were offered a stable where the Christ Child was soon born, with angels"
    secondLabel.text = "The celebratory customs associated in various countries with Christmas have a mix of pre-Christian"
    thirdLabel.text = "The economic impact of Christmas has grown steadily over the past few centuries in many regions of the world."
    myLabel.numberOfLines = 0
    firstLabel.numberOfLines = 0
    secondLabel.numberOfLines = 0
    thirdLabel.numberOfLines = 0
    myLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    firstLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    secondLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    thirdLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    myLabel.adjustsFontForContentSizeCategory = true
    firstLabel.adjustsFontForContentSizeCategory = true
    secondLabel.adjustsFontForContentSizeCategory = true
    thirdLabel.adjustsFontForContentSizeCategory = true

    myLabel.lineBreakMode = .byWordWrapping
    firstLabel.lineBreakMode = .byWordWrapping
    secondLabel.lineBreakMode = .byWordWrapping
    thirdLabel.lineBreakMode = .byWordWrapping
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {

   if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory {
   self.myLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    self.firstLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    self.secondLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
    self.thirdLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)



wait I’m confused now, did you solve it?

if not i think it would better illustrate if you post your custom storyboard of the customcell