diff --git a/SwiftSideslipLikeQQ.xcodeproj/project.xcworkspace/xcuserdata/JohnLui.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftSideslipLikeQQ.xcodeproj/project.xcworkspace/xcuserdata/JohnLui.xcuserdatad/UserInterfaceState.xcuserstate index bfaec2e..3986ed7 100644 Binary files a/SwiftSideslipLikeQQ.xcodeproj/project.xcworkspace/xcuserdata/JohnLui.xcuserdatad/UserInterfaceState.xcuserstate and b/SwiftSideslipLikeQQ.xcodeproj/project.xcworkspace/xcuserdata/JohnLui.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SwiftSideslipLikeQQ/AppDelegate.swift b/SwiftSideslipLikeQQ/AppDelegate.swift index 5257f48..cac3f88 100644 --- a/SwiftSideslipLikeQQ/AppDelegate.swift +++ b/SwiftSideslipLikeQQ/AppDelegate.swift @@ -20,11 +20,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // 改变 StatusBar 颜色 application.statusBarStyle = UIStatusBarStyle.LightContent - // 改变 navigation bar 的背景色 + // 改变 navigation bar 的背景色及前景色 let navigationBarAppearace = UINavigationBar.appearance() navigationBarAppearace.translucent = false navigationBarAppearace.barTintColor = UIColor(hex: 0x25b6ed) - navigationBarAppearace.tintColor = UIColor.whiteColor() navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()] diff --git a/SwiftSideslipLikeQQ/Common.swift b/SwiftSideslipLikeQQ/Common.swift index 15391fa..3b52ffa 100644 --- a/SwiftSideslipLikeQQ/Common.swift +++ b/SwiftSideslipLikeQQ/Common.swift @@ -9,6 +9,7 @@ import UIKit struct Common { + // Swift 中, static let 才是真正可靠好用的单例模式 static let screenWidth = UIScreen.mainScreen().applicationFrame.maxX static let screenHeight = UIScreen.mainScreen().applicationFrame.maxY static let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController as! ViewController diff --git a/SwiftSideslipLikeQQ/HomeViewController.swift b/SwiftSideslipLikeQQ/HomeViewController.swift index 3948530..36ed70f 100644 --- a/SwiftSideslipLikeQQ/HomeViewController.swift +++ b/SwiftSideslipLikeQQ/HomeViewController.swift @@ -8,6 +8,7 @@ import UIKit +// 主页 class HomeViewController: UIViewController { var titleOfOtherPages = "" diff --git a/SwiftSideslipLikeQQ/LeftViewController.swift b/SwiftSideslipLikeQQ/LeftViewController.swift index bf8b99b..94667cb 100644 --- a/SwiftSideslipLikeQQ/LeftViewController.swift +++ b/SwiftSideslipLikeQQ/LeftViewController.swift @@ -8,6 +8,7 @@ import UIKit +// 侧滑菜单 View Controller class LeftViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { let titlesDictionary = ["开通会员", "QQ钱包", "网上营业厅", "个性装扮", "我的收藏", "我的相册", "我的文件"] @@ -33,6 +34,7 @@ class LeftViewController: UIViewController, UITableViewDelegate, UITableViewData // Dispose of any resources that can be recreated. } + // 处理点击事件 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let viewController = Common.rootViewController viewController.homeViewController.titleOfOtherPages = titlesDictionary[indexPath.row] diff --git a/SwiftSideslipLikeQQ/MainTabBarController.swift b/SwiftSideslipLikeQQ/MainTabBarController.swift index b6d3264..1e0977f 100644 --- a/SwiftSideslipLikeQQ/MainTabBarController.swift +++ b/SwiftSideslipLikeQQ/MainTabBarController.swift @@ -8,6 +8,7 @@ import UIKit +// TabBar Controller,主页所有内容的父容器 class MainTabBarController: UITabBarController { override func viewDidLoad() { @@ -21,11 +22,13 @@ class MainTabBarController: UITabBarController { // Dispose of any resources that can be recreated. } + // 覆写了 TabBar 的点击效果 override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) { switch item.tag { case 0: Common.contactsVC.view.removeFromSuperview() case 1: + // 这里为了省事采用了简单的 addSubView 方案,真正项目中应该采用 TabBar Controller 自带的 self.viewControllers 方案 Common.rootViewController.mainTabBarController.view.addSubview(Common.contactsVC.view) Common.rootViewController.mainTabBarController.view.bringSubviewToFront(Common.rootViewController.mainTabBarController.tabBar) case 2: diff --git a/SwiftSideslipLikeQQ/OtherPageViewController.swift b/SwiftSideslipLikeQQ/OtherPageViewController.swift index 8243cca..6073fbb 100644 --- a/SwiftSideslipLikeQQ/OtherPageViewController.swift +++ b/SwiftSideslipLikeQQ/OtherPageViewController.swift @@ -8,6 +8,7 @@ import UIKit +// 点击侧滑菜单中的条目,主页跳转到的 View Controller class OtherPageViewController: UIViewController { var PageTitle: String! // 从 HomeViewController 传递过来的值