-
Notifications
You must be signed in to change notification settings - Fork 101
/
TabBarController.swift
55 lines (43 loc) · 1.23 KB
/
TabBarController.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// TabBarController.swift
// PinGo
//
// Created by GaoWanli on 16/1/16.
// Copyright © 2016年 GWL. All rights reserved.
//
import UIKit
class TabBarController: UITabBarController {
@IBOutlet fileprivate weak var aTabBar: TabBar!
override func viewDidLoad() {
super.viewDidLoad()
aTabBar.aDelegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
removeSystemTabbarSubviews()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
removeSystemTabbarSubviews()
}
fileprivate func removeSystemTabbarSubviews() {
for v in tabBar.subviews {
if v.superclass == UIControl.self {
v.removeFromSuperview()
}
}
}
}
extension TabBarController: TabBarDelegate {
func tabBar(_ tabBar: TabBar, didClickButton index: Int) {
var index = index
if index == 2 {
let showVC = UIStoryboard.initialViewController("Show")
present(showVC, animated: true, completion: nil)
return
}else if index >= 2 {
index -= 1
}
selectedIndex = index
}
}