Put following lines of code in your viewController.
E.g. I’ve added code in viewDidLoad

class YourViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()

    // Code to check size class <--------------
    if traitCollection.horizontalSizeClass == .compact {
      // update view as per compact settings
    } else {
      // update your view as per regular settings
    }
    // --- end
  }
}