2. Controllers of the Screens

For each different screen (red, blue, and green), we need to have different Controllers. Let's create three controller files.

RedViewController.swift

//
//  RedViewController.swift
//  TabControllerDemo
//
//  Created by Sakib Miazi on 6/6/23.
//

import UIKit

class RedViewController: UIViewController {
    let redView = RedView()
    
    override func loadView() {
        view = redView
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        title = "Red"
    }
}

BlueViewController.swift

GreenViewController.swift

Last updated

Was this helpful?