Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import UIKit

class ViewController: UIViewController {

private let button: UIButton = {


let button = UIButton(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
button.setTitle("Login", for: .normal)
button.backgroundColor = .white
button.setTitleColor(.black, for: .normal)
return button
}()

override func viewDidLoad() {


super.viewDidLoad()

view.backgroundColor = .systemBlue
view.addSubview(button)
button.addTarget(self, action: #selector(didTapLogin), for: .touchUpInside)
}

override func viewDidLayoutSubviews() {


super.viewDidLayoutSubviews()
button.center = view.center
}

@objc func didTapLogin() {


let tabBarVC = UITabBarController()

let vc1 = UINavigationController(rootViewController: FirstViewController())


let vc2 = UINavigationController(rootViewController:
SecondViewController())
let vc3 = UINavigationController(rootViewController: ThirdViewController())
let vc4 = UINavigationController(rootViewController:
FourthViewController())
let vc5 = UINavigationController(rootViewController: FifthViewController())

vc1.title = "Home"
vc2.title = "Checklist Report"
vc3.title = "Damage Report"
vc4.title = "Roadside Report"
vc5.title = "More Options"

tabBarVC.setViewControllers([vc1, vc2, vc3, vc4, vc5], animated: false)

guard let items = tabBarVC.tabBar.items else {


return
}

let icons = ["house", "bell", "person.circle", "star", "gear"]

for x in 0..<items.count {
items[0].badgeValue = "1"
items[1].badgeValue = "2"
items[2].badgeValue = "3"
items[3].badgeValue = "4"
items[4].badgeValue = "5"
items[x].image = UIImage(systemName: icons[x])
}
tabBarVC.modalPresentationStyle = .fullScreen
present(tabBarVC, animated: true)
}
}

class FirstViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
title = "Home"
}
}

class SecondViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .yellow
title = "Checklist Report"
}
}

class ThirdViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .lightGray
title = "Damage Report"
}
}

class FourthViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .purple
title = "Roadside Report"
}
}

class FifthViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .orange
title = "More Options"
}
}

You might also like