zoukankan      html  css  js  c++  java
  • 纯代码搭建项目框架

    一.修改项目的启动过程

    • 将Main Interface处的main删除
    • 在application:didFinishLaunchingWithOptions:launchOptions:方法中创建window,并且设置根控制器
        // 设置整体主题TabBar的tintColor
        UITabBar.appearance().tintColor = UIColor.orangeColor()
    
        // 1.创建window
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
        self.window?.backgroundColor = UIColor.whiteColor()
    
        // 2.设置window的根控制器
        self.window?.rootViewController = MainViewController()
    
        // 3.让窗口生效
        self.window?.makeKeyAndVisible()
    
    • 在MainViewController中添加子控制器
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // 添加自控制器
            self.addChildViewController(HomeViewController(), imageName: "tabbar_home", title: "主页")
            self.addChildViewController(MessageViewController(), imageName: "tabbar_message_center", title: "消息")
            self.addChildViewController(DiscoverViewController(), imageName: "tabbar_discover", title: "广场")
            self.addChildViewController(ProfileViewController(), imageName: "tabbar_profile", title: "我")
        }
    
        private func addChildViewController(childCVc: UIViewController, imageName : String, title : String) {
            // 1.创建自控制器
            let homeNav = UINavigationController(rootViewController: childCVc)
    
            // 2.设置标题
            childCVc.title = title
            childCVc.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")
            childCVc.tabBarItem.image = UIImage(named: imageName)
    
            // 3.添加到UITabbarController
            self.addChildViewController(homeNav)
        }
  • 相关阅读:
    Computability 2: Gödel Number
    Computability 1: Computational Models
    Axiomatic Set Theory
    External Sorting Model
    Minimum Spanning Tree
    All-Pairs Shortest Paths
    Python 泰坦尼克生存率预测(修改)
    Python 分析Kaggle_Titanic案例
    Python 北京二手房成交数据分析过程
    数据挖掘主要解决的四类问题以及常用到的算法
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/7414144.html
Copyright © 2011-2022 走看看