-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathAuthTabBarViewController.swift
41 lines (32 loc) · 1.41 KB
/
AuthTabBarViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import UIKit
class AuthTabBarViewController: UITabBarController {
@IBOutlet weak var backButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
setBackButton()
}
func setBackButton() {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "back"), for: .normal)
button.addTarget(self, action: #selector(AuthTabBarViewController.backAction), for: .touchUpInside)
button.frame = CGRect(x: 0, y: 0, width: 53, height: 31)
button.imageEdgeInsets = UIEdgeInsetsMake(1, -32, 1, 32)
let label = UILabel(frame: CGRect(x: 3, y: 5, width: 50, height: 20))
label.text = "Back"
label.textAlignment = .center
label.textColor = UIColor.white
label.backgroundColor = UIColor.clear
button.addSubview(label)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.leftBarButtonItem = barButton
}
@objc func backAction() {
let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
guard let vc: UITabBarController = mainStoryboard.instantiateViewController(withIdentifier: "tabBarController") as? UITabBarController else {
fatalError("Cannot Cast to UITabBarController")
}
vc.modalPresentationStyle = .fullScreen
vc.selectedIndex = 0
self.present(vc, animated: true, completion: nil)
}
}