[绍棠_Swift] Swift3.0中别的类获取APPDelegate及UITabbarViewController的自定义
来源:互联网 发布:印度航母 知乎 编辑:程序博客网 时间:2024/06/02 03:11
let appDelegate: AppDelegate = UIApplication.shared.delegateas! AppDelegate
自定义tabbarcontroller
extension BYMainTabBarController {
fileprivatefunc setUpChildViewController() {
let homeVC =BYHomeViewController()
setUpNavRootViewControllers(vc: homeVC, title:"精选", image:"found@2x.png", selImage:"found_s@2x.png")
let channelVC =BYChannelViewController()
setUpNavRootViewControllers(vc: channelVC, title:"频道", image:"message@2x.png", selImage:"message_s@2x.png")
let setVC =BYSettingViewController()
setUpNavRootViewControllers(vc: setVC, title:"设置", image:"share@2x.png", selImage:"share_s@2x.png")
}
// 初始化一个到导航控制器的控制器
fileprivatefunc setUpNavRootViewControllers(vc:UIViewController, title:String, image: String, selImage:String){
vc.title = title
vc.tabBarItem.image =UIImage(named: image)
vc.tabBarItem.selectedImage =UIImage.mg_RenderModeOriginal(imageName: selImage)
self.addChildViewController(BaseNavController(rootViewController: vc))
}
}
class BYMainTabBarController: UITabBarController {
overridefunc viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setUpChildViewController() // 初始化所有的子控制器
}
overridefunc didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
APPDelegate的设置
func application(_ application:UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:Any]?) -> Bool {
// Override point for customization after application launch.
/** !号
*1.声明Optional值变量
*2.用在对Optional值操作中,用来判断是否能响应后面的操作
*/
/** ?号
*1.强制对Optional值进行拆包(unwrap)
*2.声明Implicitly Unwrapped Optionals值,一般用于类中的属性
*/
let bYTabBar =BYMainTabBarController()
self.window!.rootViewController = bYTabBar;
self.window!.rootViewController = loginVC
// self.window!.rootViewController = nav1
self.window?.makeKeyAndVisible()
returntrue
}
- [绍棠_Swift] Swift3.0中别的类获取APPDelegate及UITabbarViewController的自定义
- [绍棠_Swift] Swift3.0中代理的使用方法
- [绍棠_Swift] Swift3.0中自定义导航栏后侧滑返回功能失效
- [绍棠_Swift] Swift3.0中如何获取Info.plist文件信息
- [绍棠_Swift] Swift3.0中使用CocoaPods导入的第三方库
- [绍棠_Swift] Swift3.0中Get、Post的同步与异步请求
- [绍棠_Swift] Swift3.0中guard语句的使用和理解
- [绍棠_Swift] Swift3.0中可能用到的第三方框架
- [绍棠_swift] Swift3.0的学习枚举、断言、函数嵌套
- [绍棠_Swift] Swift3.0中的Alamofire网络请求的封装
- [绍棠_Swift] Swift3.0笔记整理
- [绍棠_Swift] Swift3.0中的GCD
- [绍棠_Swift] Swift3.0中 通过viewController push跳转到TabbarController 隐藏后退按钮问题
- [绍棠_Swift] Swift3.0中tableviewcell分割线显示不全解决方案
- [绍棠_Swift] Swift中类和结构体的区别
- 自定义UITabBarViewController
- 在Appdelegate中获取当前的ViewController
- 在MFC类中获取别的类的指针
- Spring学习目录
- 《leetCode》:Longest Substring Without Repeating Characters
- oralce truncate 后查看上次数据
- spring boot更改配置文件 application.properties的位置
- 欧拉函数代码实现
- [绍棠_Swift] Swift3.0中别的类获取APPDelegate及UITabbarViewController的自定义
- Xshell 输入中文显示?? 解决办法
- 数据库 和 JAVA 的类型比较
- 获取DataTabl的第一行和最后一行的数据
- mysql 数据库清理 磁盘空间
- SpringMVC 手动配置Bean和自动注册Bean
- 绘图笔记
- 堆栈溢出
- 51nod 1040 最大公约数之和