Skip to content

Commit 810daf3

Browse files
committed
add some comment
1 parent 4009b6a commit 810daf3

File tree

7 files changed

+9
-2
lines changed

7 files changed

+9
-2
lines changed

SwiftSideslipLikeQQ/AppDelegate.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2020
// 改变 StatusBar 颜色
2121
application.statusBarStyle = UIStatusBarStyle.LightContent
2222

23-
// 改变 navigation bar 的背景色
23+
// 改变 navigation bar 的背景色及前景色
2424
let navigationBarAppearace = UINavigationBar.appearance()
2525
navigationBarAppearace.translucent = false
2626
navigationBarAppearace.barTintColor = UIColor(hex: 0x25b6ed)
27-
2827
navigationBarAppearace.tintColor = UIColor.whiteColor()
2928
navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]
3029

SwiftSideslipLikeQQ/Common.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import UIKit
1010

1111
struct Common {
12+
// Swift 中, static let 才是真正可靠好用的单例模式
1213
static let screenWidth = UIScreen.mainScreen().applicationFrame.maxX
1314
static let screenHeight = UIScreen.mainScreen().applicationFrame.maxY
1415
static let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController as! ViewController

SwiftSideslipLikeQQ/HomeViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010

11+
// 主页
1112
class HomeViewController: UIViewController {
1213

1314
var titleOfOtherPages = ""

SwiftSideslipLikeQQ/LeftViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010

11+
// 侧滑菜单 View Controller
1112
class LeftViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
1213

1314
let titlesDictionary = ["开通会员", "QQ钱包", "网上营业厅", "个性装扮", "我的收藏", "我的相册", "我的文件"]
@@ -33,6 +34,7 @@ class LeftViewController: UIViewController, UITableViewDelegate, UITableViewData
3334
// Dispose of any resources that can be recreated.
3435
}
3536

37+
// 处理点击事件
3638
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
3739
let viewController = Common.rootViewController
3840
viewController.homeViewController.titleOfOtherPages = titlesDictionary[indexPath.row]

SwiftSideslipLikeQQ/MainTabBarController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010

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

1314
override func viewDidLoad() {
@@ -21,11 +22,13 @@ class MainTabBarController: UITabBarController {
2122
// Dispose of any resources that can be recreated.
2223
}
2324

25+
// 覆写了 TabBar 的点击效果
2426
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
2527
switch item.tag {
2628
case 0:
2729
Common.contactsVC.view.removeFromSuperview()
2830
case 1:
31+
// 这里为了省事采用了简单的 addSubView 方案,真正项目中应该采用 TabBar Controller 自带的 self.viewControllers 方案
2932
Common.rootViewController.mainTabBarController.view.addSubview(Common.contactsVC.view)
3033
Common.rootViewController.mainTabBarController.view.bringSubviewToFront(Common.rootViewController.mainTabBarController.tabBar)
3134
case 2:

SwiftSideslipLikeQQ/OtherPageViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010

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

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

0 commit comments

Comments
 (0)