Skip to content

Commit

Permalink
add some comment
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlui committed Sep 12, 2015
1 parent 4009b6a commit 810daf3
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 2 deletions.
Binary file not shown.
3 changes: 1 addition & 2 deletions SwiftSideslipLikeQQ/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()]

Expand Down
1 change: 1 addition & 0 deletions SwiftSideslipLikeQQ/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions SwiftSideslipLikeQQ/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

// 主页
class HomeViewController: UIViewController {

var titleOfOtherPages = ""
Expand Down
2 changes: 2 additions & 0 deletions SwiftSideslipLikeQQ/LeftViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

// 侧滑菜单 View Controller
class LeftViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

let titlesDictionary = ["开通会员", "QQ钱包", "网上营业厅", "个性装扮", "我的收藏", "我的相册", "我的文件"]
Expand All @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions SwiftSideslipLikeQQ/MainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

// TabBar Controller,主页所有内容的父容器
class MainTabBarController: UITabBarController {

override func viewDidLoad() {
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions SwiftSideslipLikeQQ/OtherPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

// 点击侧滑菜单中的条目,主页跳转到的 View Controller
class OtherPageViewController: UIViewController {

var PageTitle: String! // 从 HomeViewController 传递过来的值
Expand Down

0 comments on commit 810daf3

Please sign in to comment.