CNLiveBaseTabBarViewController.swift
3.78 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// CNLiveBaseTabbarViewController.swift
// metaCode
//
// Created by daojian on 2023/6/5.
//
import Foundation
import UIKit
class CNTabBar:UITabBar{
override var frame: CGRect {
willSet
{
}
//我们需要在age属性发生变化后,更新一下nickName这个属性
didSet
{
// print("frame = ", frame)
// print("完成")
}
}
}
class CNLiveBaseTabBarViewController: UITabBarController
{
override func viewDidLoad() {
super.viewDidLoad()
self.setValue(CNTabBar.init(), forKey: "tabBar")
self.setUpTabBar()
self.setupBackgroup()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
print("获取用户用户数据=====>\(UserInfoManager.shared.userInfo.uid)")
//已经弹出过就不用再弹框了
if ConfigManager.shared.show_update {
CNLiveMineViewModel.requestSystemNews { result, respStatue in
if respStatue == .success {
UpdataAlertView.showUpdataView(updataModel: result as! UpdateInfoModel)
}
}
}
}
// MARK: - 控制器的信息
func setUpTabBar() {
//// let homeVC = CNLiveNewAuthViewController.init()
///忽必烈
let homeVC = CNLiveTVHomeViewController.init()
// let homeVC = CNLiveAuthViewController.init()
// let homeVC = CNHomeWebViewController()
// homeVC.url = URL(string: "https://wjjh5.cnlive.com/chatgpt/#/")
// let authVC = CNMetaCodeHomePageController.init()
let mineVC = CNLiveMineViewController.init()
creatTabbarView(viewController: homeVC, image: "tabbar_hoem_icon_default", selectImage: "tabbar_hoem_icon_selected", title: "首页")
// creatTabbarView(viewController: authVC, image: "tabbar_authentication_unSelect", selectImage: "tabbar_authentication", title: "认证")
creatTabbarView(viewController: mineVC, image: "tabbar_mine_icon_default", selectImage: "tabbar_mine_icon_selected", title: "我的")
self.tabBar.tintColor = UIColor("#0066FE")
self.tabBar.isTranslucent = false
self.viewControllers = [
CNLiveBaseNavigationController(rootViewController: homeVC),
//CNLiveBaseNavigationController(rootViewController: authVC),
CNLiveBaseNavigationController(rootViewController: mineVC)
]
// self.selectedIndex = 1
}
// MARK: - Tabar 背景图
func setupBackgroup(){
if #available(iOS 13.0, *) {
let appearance: UITabBarAppearance = UITabBarAppearance.init()
appearance.configureWithTransparentBackground()
appearance.backgroundColor = UIColor.clear
appearance.backgroundImage = UIImage(named: "tabbar_backgroup")
if #available(iOS 15.0, *) {
tabBar.scrollEdgeAppearance = appearance
} else {
// Fallback on earlier versions
tabBar.standardAppearance = appearance
}
} else {
tabBar.backgroundColor = .clear
tabBar.backgroundImage = UIImage(named: "tabbar_backgroup")
}
}
// MARK: - TabBar里面的文字图片
func creatTabbarView(viewController:UIViewController, image:NSString, selectImage:NSString, title:NSString) {
// alwaysOriginal 始终绘制图片原始状态,不使用Tint Color。
viewController.tabBarItem.image = UIImage(named: image as String)?.withRenderingMode(.alwaysOriginal)
viewController.tabBarItem.selectedImage = UIImage(named: selectImage as String)?.withRenderingMode(.alwaysOriginal)
viewController.title = title as String
}
}