title: Adding Gradient View and UILabel Programmatically to a UIView Is Not Working
body: <p>I have a Storyboard with three UIViews set up and connected to the storyboard's UIViewController.</p>
  
  <pre><code>@IBOutlet weak var availableView: UIView!
  @IBOutlet weak var maybeAvailableView: UIView!
  @IBOutlet weak var notAvailableView: UIView!
  </code></pre>
  
  <p>I have two functions to add a UILabel and CAGradientLayer to each of the UIViews. This one's for adding the UILabels.</p>
  
  <pre><code>func setUpLabels(view1: UIView, view2: UIView, view3: UIView) {
      let availableLabel = UILabel()
      let maybeAvailableLabel = UILabel()
      let notAvailableLabel = UILabel()
  
      availableLabel.text = "Available"
      maybeAvailableLabel.text = "Maybe Available"
      notAvailableLabel.text = "Not Available"
  
      availableLabel.backgroundColor = .clear
      maybeAvailableLabel.backgroundColor = .clear
      notAvailableLabel.backgroundColor = .clear
  
      availableLabel.font = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight(rawValue: 10))
      maybeAvailableLabel.font = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight(rawValue: 10))
      notAvailableLabel.font = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight(rawValue: 10))
  
      availableLabel.textColor = .black
      maybeAvailableLabel.textColor = .black
      notAvailableLabel.textColor = .black
  
      availableLabel.frame = view1.bounds
      maybeAvailableLabel.frame = view2.bounds
      notAvailableLabel.frame = view3.bounds
  
      view1.addSubview(availableLabel)
      view2.addSubview(maybeAvailableLabel)
      view3.addSubview(notAvailableLabel)
  }
  </code></pre>
  
  <p>This one's for adding the gradients.</p>
  
  <pre><code>func setGradientBackground(colorTop: UIColor, colorBottom: UIColor, view: UIView) {
  let gradientLayer = CAGradientLayer()
  gradientLayer.colors = [colorBottom.cgColor, colorTop.cgColor]
  gradientLayer.startPoint = CGPoint(x: 1, y: 1)
  gradientLayer.endPoint = CGPoint(x: 0, y: 0)
  gradientLayer.locations = [0, 1]
  gradientLayer.frame = view.bounds
  
  view.layer.insertSublayer(gradientLayer, at: 0)
  }
  </code></pre>
  
  <p>This is what I call in viewDidLayoutSubviews</p>
  
  <pre><code>availableView.layer.masksToBounds = true
  maybeAvailableView.layer.masksToBounds = true
  notAvailableView.layer.masksToBounds = true
  
  setGradientBackground(colorTop: darkBlue, colorBottom: .systemIndigo, view: notAvailableView)
  setGradientBackground(colorTop: .systemRed, colorBottom: .systemOrange, view: maybeAvailableView)
  setGradientBackground(colorTop: .systemBlue, colorBottom: .systemTeal, view: availableView)
  
  setUpLabels(view1: availableView, view2: maybeAvailableView, view3: notAvailableView)
  </code></pre>
  
  <p>However, nothing appears in the viewController or in the debug hierarchy view. I've tried many things from other questions but nothing changes.</p>