How to create Onboarding\Walkthrough swift

I’m trying to create a welcome onboarding for the first time users but none of the views are loafing in the simulator, all I’m getting is a red background when the onboardingVC gets presented. Can anyone see the issue as to why the titles, buttons, and images won’t appear?

This is the message I’m getting in the console:

Warning: Attempt to present <EMA.WalkthroughVC: 0x7faa2401e5b0> on <EMA.HomeVC: 0x7faa22407e00> whose view is not in the window hierarchy! FOUND ALL!!

let holderView: UIView = {     let view = UIView()         view.translatesAutoresizingMaskIntoConstraints = true         view.backgroundColor = .darkGray         return view     }()          override func viewDidLoad() {         super.viewDidLoad()         view.backgroundColor = UIColor.white     }          override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews()         view.backgroundColor = UIColor.red         configure()     }          private func configure() {         let scrollView = UIScrollView(frame: holderView.bounds)         holderView.addSubview(scrollView)                  let titles = ["Hi","Welcome","real nigga"]                  for x in 0..<3 {             let pageView = UIView(frame: CGRect(x: CGFloat(x) * holderView.frame.size.width, y: 0, width: holderView.frame.size.width, height: holderView.frame.size.height))             scrollView.addSubview(pageView)                          let label = UILabel(frame: CGRect(x: 10, y: 10, width: pageView.frame.size.width-20, height: 120))                          let imageView = UIImageView(frame: CGRect(x: 10, y: 10+120+10, width: pageView.frame.size.width-20, height: pageView.frame.size.height - 60 - 130 - 15))                          let button = UIButton(frame: CGRect(x: 10, y: pageView.frame.size.height - 60, width: pageView.frame.size.width-20, height: 50))                          label.textAlignment = .center             label.font = UIFont.systemFont(ofSize: 16, weight: .semibold)             pageView.addSubview(label)             label.text = titles[x]                          imageView.contentMode = .scaleAspectFill             imageView.image = UIImage(named: "BankCard\(x)")             pageView.addSubview(imageView)                          button.setTitleColor(.red, for: .normal)             button.backgroundColor = .black             button.setTitle("Continue", for: .normal)             if x == 2 {                 button.setTitle("Get Started", for: .normal)             }             button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside)             pageView.addSubview(button)          }     }          @objc func didTapButton(_ button: UIButton) {              }  } 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.