From e78087782a48878503617828c4d29adeb3c0e19e Mon Sep 17 00:00:00 2001 From: JohnLui Date: Mon, 17 Oct 2016 10:28:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0Swift=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SwiftColors.swift | 22 +++--- SwiftSideslipLikeQQ.xcodeproj/project.pbxproj | 13 +++- .../UserInterfaceState.xcuserstate | Bin 21308 -> 19857 bytes .../xcschemes/SwiftSideslipLikeQQ.xcscheme | 2 +- SwiftSideslipLikeQQ/AppDelegate.swift | 20 +++--- SwiftSideslipLikeQQ/Common.swift | 8 +-- SwiftSideslipLikeQQ/HomeViewController.swift | 8 +-- SwiftSideslipLikeQQ/LeftViewController.swift | 24 +++---- .../MainTabBarController.swift | 4 +- .../OtherPageViewController.swift | 8 +-- SwiftSideslipLikeQQ/ViewController.swift | 64 +++++++++--------- .../SwiftSideslipLikeQQTests.swift | 2 +- 12 files changed, 93 insertions(+), 82 deletions(-) diff --git a/SwiftColors.swift b/SwiftColors.swift index fd2d630..521ee53 100644 --- a/SwiftColors.swift +++ b/SwiftColors.swift @@ -52,31 +52,31 @@ extension SWColor { // Check for hash and remove the hash if hex.hasPrefix("#") { - hex = hex.substringFromIndex(hex.startIndex.advancedBy(1)) + hex = hex.substring(from: hex.characters.index(hex.startIndex, offsetBy: 1)) } - if let _ = hex.rangeOfString("(^[0-9A-Fa-f]{6}$)|(^[0-9A-Fa-f]{3}$)", options: .RegularExpressionSearch) { + if let _ = hex.range(of: "(^[0-9A-Fa-f]{6}$)|(^[0-9A-Fa-f]{3}$)", options: .regularExpression) { // Deal with 3 character Hex strings if hex.characters.count == 3 { - let redHex = hex.substringToIndex(hex.startIndex.advancedBy(1)) - let greenHex = hex.substringWithRange(Range(start: hex.startIndex.advancedBy(1), end: hex.startIndex.advancedBy(2))) - let blueHex = hex.substringFromIndex(hex.startIndex.advancedBy(2)) + let redHex = hex.substring(to: hex.characters.index(hex.startIndex, offsetBy: 1)) + let greenHex = hex.substring(with: (hex.characters.index(hex.startIndex, offsetBy: 1) ..< hex.characters.index(hex.startIndex, offsetBy: 2))) + let blueHex = hex.substring(from: hex.characters.index(hex.startIndex, offsetBy: 2)) hex = redHex + redHex + greenHex + greenHex + blueHex + blueHex } - let redHex = hex.substringToIndex(hex.startIndex.advancedBy(2)) - let greenHex = hex.substringWithRange(Range(start: hex.startIndex.advancedBy(2), end: hex.startIndex.advancedBy(4))) - let blueHex = hex.substringWithRange(Range(start: hex.startIndex.advancedBy(4), end: hex.startIndex.advancedBy(6))) + let redHex = hex.substring(to: hex.characters.index(hex.startIndex, offsetBy: 2)) + let greenHex = hex.substring(with: (hex.characters.index(hex.startIndex, offsetBy: 2) ..< hex.characters.index(hex.startIndex, offsetBy: 4))) + let blueHex = hex.substring(with: (hex.characters.index(hex.startIndex, offsetBy: 4) ..< hex.characters.index(hex.startIndex, offsetBy: 6))) var redInt: CUnsignedInt = 0 var greenInt: CUnsignedInt = 0 var blueInt: CUnsignedInt = 0 - NSScanner(string: redHex).scanHexInt(&redInt) - NSScanner(string: greenHex).scanHexInt(&greenInt) - NSScanner(string: blueHex).scanHexInt(&blueInt) + Scanner(string: redHex).scanHexInt32(&redInt) + Scanner(string: greenHex).scanHexInt32(&greenInt) + Scanner(string: blueHex).scanHexInt32(&blueInt) self.init(red: CGFloat(redInt) / 255.0, green: CGFloat(greenInt) / 255.0, blue: CGFloat(blueInt) / 255.0, alpha: CGFloat(alpha)) } diff --git a/SwiftSideslipLikeQQ.xcodeproj/project.pbxproj b/SwiftSideslipLikeQQ.xcodeproj/project.pbxproj index 3f6bacb..8643603 100644 --- a/SwiftSideslipLikeQQ.xcodeproj/project.pbxproj +++ b/SwiftSideslipLikeQQ.xcodeproj/project.pbxproj @@ -179,14 +179,16 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = com.lvwenhan; TargetAttributes = { 465933041AD7F60700969878 = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0800; }; 465933191AD7F60700969878 = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0800; TestTargetID = 465933041AD7F60700969878; }; }; @@ -298,8 +300,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -343,8 +347,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -363,6 +369,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -376,6 +383,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.lvwenhan.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -388,6 +396,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.lvwenhan.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -407,6 +416,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.lvwenhan.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftSideslipLikeQQ.app/SwiftSideslipLikeQQ"; }; name = Debug; @@ -423,6 +433,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.lvwenhan.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftSideslipLikeQQ.app/SwiftSideslipLikeQQ"; }; name = Release; diff --git a/SwiftSideslipLikeQQ.xcodeproj/project.xcworkspace/xcuserdata/JohnLui.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftSideslipLikeQQ.xcodeproj/project.xcworkspace/xcuserdata/JohnLui.xcuserdatad/UserInterfaceState.xcuserstate index 3986ed77bd3cf8307d8480ec76413b388fcc8607..8a669ba3ea504c9cf6faadde05ddd64efe3f44dc 100644 GIT binary patch delta 10847 zcmaKR2V7HE`~N-T29iKn8IV9o5F(He0vUvaB;cT;s3^Dxq99Tg6mXa3T&=sc>TMm> zsvv5swsqA#Yu&5v+F@&JwXfA`tF5Ee{!fB9-nYMh?I+xO&U2pgJm*>8=iHqu!JI{4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{n0-0>O7`{a8`(c*Kgr?e zC~|Uhs&eM!EXk?MS)Q{hXKl{9oKJI(<($Ylm2)QN>zwmBw{sp@ffZW)tU*?RHQ3tR z8fs0p8m$(q)#|Y3SzB5Qt=+6Wt$nQhto^MO)+%eQ+d9%Z#yZYA%{s$6+v>5tYkl9k z!n)e}fpvp*vvsR=uXUewzxAN?l=Xu3Tk93;b?Xn-+tz#5`_>26ht@~7W;UHI&(_;k zYAdr<*s5%`wh^|8wn?_hwzq6cZR>0sZCh*~*>>1=**>!!u^qJ?v;AiK$KK2?vNyMj z?J~PN(yp{e+hgqsc8fj7Znrz_E$yxC?d%=wo$Q77uJ$+VlkD^DtL=O3XY6+ztRun^ z&k1&*$c9*$m)!H!{$N=LP0q+_&WoWt!H@0jG6;+W@{ z?^xtm>R9erp0*z>^SOnoOGOaoO7IaTy$J<{Ob5Kw|VZ$+>N=La<}Au znEOfYr@4D`kLG@!`$g{g+)KHabFb!ppZi1Z?c6_e|IU4s`_u`X&72|5FsIZhcdDFf zXROocbT~UW3!UAZJ)K3){!W*3kh9kLrgOS;w$tN$*SXNS#98NTaBg$%aem=6o^qaX qe(k*EyzIQ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. // 改变 StatusBar 颜色 - application.statusBarStyle = UIStatusBarStyle.LightContent + application.statusBarStyle = UIStatusBarStyle.lightContent // 改变 navigation bar 的背景色及前景色 let navigationBarAppearace = UINavigationBar.appearance() - navigationBarAppearace.translucent = false + navigationBarAppearace.isTranslucent = false navigationBarAppearace.barTintColor = UIColor(hex: 0x25b6ed) - navigationBarAppearace.tintColor = UIColor.whiteColor() - navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()] + navigationBarAppearace.tintColor = UIColor.white + navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white] return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/SwiftSideslipLikeQQ/Common.swift b/SwiftSideslipLikeQQ/Common.swift index 3b52ffa..a0ecc24 100644 --- a/SwiftSideslipLikeQQ/Common.swift +++ b/SwiftSideslipLikeQQ/Common.swift @@ -10,8 +10,8 @@ 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 - static let contactsVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("Contacts") + static let screenWidth = UIScreen.main.applicationFrame.maxX + static let screenHeight = UIScreen.main.applicationFrame.maxY + static let rootViewController = UIApplication.shared.keyWindow?.rootViewController as! ViewController + static let contactsVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Contacts") } diff --git a/SwiftSideslipLikeQQ/HomeViewController.swift b/SwiftSideslipLikeQQ/HomeViewController.swift index 36ed70f..91352c8 100644 --- a/SwiftSideslipLikeQQ/HomeViewController.swift +++ b/SwiftSideslipLikeQQ/HomeViewController.swift @@ -20,8 +20,8 @@ class HomeViewController: UIViewController { // 设置中间 segmentView 视图 let segmentView = UISegmentedControl(items: ["消息", "电话"]) segmentView.selectedSegmentIndex = 0 - segmentView.setWidth(60, forSegmentAtIndex: 0) - segmentView.setWidth(60, forSegmentAtIndex: 1) + segmentView.setWidth(60, forSegmentAt: 0) + segmentView.setWidth(60, forSegmentAt: 1) self.navigationItem.titleView = segmentView } @@ -35,9 +35,9 @@ class HomeViewController: UIViewController { // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "showOtherPages" { - if let a = segue.destinationViewController as? OtherPageViewController { + if let a = segue.destination as? OtherPageViewController { a.PageTitle = titleOfOtherPages } } diff --git a/SwiftSideslipLikeQQ/LeftViewController.swift b/SwiftSideslipLikeQQ/LeftViewController.swift index 94667cb..979a187 100644 --- a/SwiftSideslipLikeQQ/LeftViewController.swift +++ b/SwiftSideslipLikeQQ/LeftViewController.swift @@ -26,7 +26,7 @@ class LeftViewController: UIViewController, UITableViewDelegate, UITableViewData settingTableView.tableFooterView = UIView() heightLayoutConstraintOfSettingTableView.constant = Common.screenHeight < 500 ? Common.screenHeight * (568 - 221) / 568 : 347 - self.view.frame = CGRectMake(0, 0, 320 * 0.78, Common.screenHeight) + self.view.frame = CGRect(x: 0, y: 0, width: 320 * 0.78, height: Common.screenHeight) } override func didReceiveMemoryWarning() { @@ -35,29 +35,29 @@ class LeftViewController: UIViewController, UITableViewDelegate, UITableViewData } // 处理点击事件 - func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let viewController = Common.rootViewController - viewController.homeViewController.titleOfOtherPages = titlesDictionary[indexPath.row] - viewController.homeViewController.performSegueWithIdentifier("showOtherPages", sender: self) + viewController.homeViewController.titleOfOtherPages = titlesDictionary[(indexPath as NSIndexPath).row] + viewController.homeViewController.performSegue(withIdentifier: "showOtherPages", sender: self) Common.contactsVC.view.removeFromSuperview() - viewController.mainTabBarController.tabBar.hidden = true + viewController.mainTabBarController.tabBar.isHidden = true viewController.mainTabBarController.selectedIndex = 0 viewController.showHome() - tableView.deselectRowAtIndexPath(indexPath, animated: false) + tableView.deselectRow(at: indexPath, animated: false) } - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 7 } - func numberOfSectionsInTableView(tableView: UITableView) -> Int { + func numberOfSections(in tableView: UITableView) -> Int { return 1 } - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("leftViewCell", forIndexPath: indexPath) + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "leftViewCell", for: indexPath) - cell.backgroundColor = UIColor.clearColor() - cell.textLabel!.text = titlesDictionary[indexPath.row] + cell.backgroundColor = UIColor.clear + cell.textLabel!.text = titlesDictionary[(indexPath as NSIndexPath).row] return cell } diff --git a/SwiftSideslipLikeQQ/MainTabBarController.swift b/SwiftSideslipLikeQQ/MainTabBarController.swift index 1e0977f..d0fd45e 100644 --- a/SwiftSideslipLikeQQ/MainTabBarController.swift +++ b/SwiftSideslipLikeQQ/MainTabBarController.swift @@ -23,14 +23,14 @@ class MainTabBarController: UITabBarController { } // 覆写了 TabBar 的点击效果 - override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) { + override func tabBar(_ tabBar: UITabBar, didSelect 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) + Common.rootViewController.mainTabBarController.view.bringSubview(toFront: Common.rootViewController.mainTabBarController.tabBar) case 2: print("Just like case 1 ↑") default: diff --git a/SwiftSideslipLikeQQ/OtherPageViewController.swift b/SwiftSideslipLikeQQ/OtherPageViewController.swift index 6073fbb..62e3da0 100644 --- a/SwiftSideslipLikeQQ/OtherPageViewController.swift +++ b/SwiftSideslipLikeQQ/OtherPageViewController.swift @@ -21,11 +21,11 @@ class OtherPageViewController: UIViewController { mainLabel.text = PageTitle // 自定义返回按钮 - let backButton = UIBarButtonItem(title: "く返回", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack") + let backButton = UIBarButtonItem(title: "く返回", style: UIBarButtonItemStyle.plain, target: self, action: #selector(OtherPageViewController.goBack)) self.navigationItem.leftBarButtonItem = backButton // 弥补因为返回按钮被替换导致的边缘滑入手势失效的问题 - let gesture = UIPanGestureRecognizer(target: self, action: "goBack") + let gesture = UIPanGestureRecognizer(target: self, action: #selector(OtherPageViewController.goBack)) self.view.addGestureRecognizer(gesture) } @@ -35,8 +35,8 @@ class OtherPageViewController: UIViewController { } func goBack() { - self.navigationController?.popViewControllerAnimated(true) - Common.rootViewController.mainTabBarController.tabBar.hidden = false + _ = self.navigationController?.popViewController(animated: true) + Common.rootViewController.mainTabBarController.tabBar.isHidden = false } /* diff --git a/SwiftSideslipLikeQQ/ViewController.swift b/SwiftSideslipLikeQQ/ViewController.swift index e72e20c..3037968 100644 --- a/SwiftSideslipLikeQQ/ViewController.swift +++ b/SwiftSideslipLikeQQ/ViewController.swift @@ -43,18 +43,18 @@ class ViewController: UIViewController { // 给根容器设置背景 let imageView = UIImageView(image: UIImage(named: "back")) - imageView.frame = UIScreen.mainScreen().bounds + imageView.frame = UIScreen.main.bounds self.view.addSubview(imageView) // 通过 StoryBoard 取出左侧侧滑菜单视图 - leftViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("LeftViewController") as! LeftViewController + leftViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LeftViewController") as! LeftViewController // 适配 4.7 和 5.5 寸屏幕的缩放操作,有偶发性小 bug if Common.screenWidth > 320 { proportionOfLeftView = Common.screenWidth / 320 distanceOfLeftView += (Common.screenWidth - 320) * FullDistance / 2 } - leftViewController.view.center = CGPointMake(leftViewController.view.center.x - 50, leftViewController.view.center.y) - leftViewController.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.8, 0.8) + leftViewController.view.center = CGPoint(x: leftViewController.view.center.x - 50, y: leftViewController.view.center.y) + leftViewController.view.transform = CGAffineTransform.identity.scaledBy(x: 0.8, y: 0.8) // 动画参数初始化 centerOfLeftViewAtBeginning = leftViewController.view.center @@ -62,44 +62,44 @@ class ViewController: UIViewController { self.view.addSubview(leftViewController.view) // 在侧滑菜单之上增加黑色遮罩层,目的是实现视差特效 - blackCover = UIView(frame: CGRectOffset(self.view.frame, 0, 0)) - blackCover.backgroundColor = UIColor.blackColor() + blackCover = UIView(frame: self.view.frame.offsetBy(dx: 0, dy: 0)) + blackCover.backgroundColor = UIColor.black self.view.addSubview(blackCover) // 初始化主视图,即包含 TabBar、NavigationBar和首页的总视图 mainView = UIView(frame: self.view.frame) // 初始化 TabBar - let nibContents = NSBundle.mainBundle().loadNibNamed("MainTabBarController", owner: nil, options: nil) - mainTabBarController = nibContents.first as! MainTabBarController + let nibContents = Bundle.main.loadNibNamed("MainTabBarController", owner: nil, options: nil) + mainTabBarController = nibContents?.first as! MainTabBarController // 取出 TabBar Controller 的视图加入主视图 let tabBarView = mainTabBarController.view - mainView.addSubview(tabBarView) + mainView.addSubview(tabBarView!) // 从 StoryBoard 取出首页的 Navigation Controller - homeNavigationController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("HomeNavigationController") as! UINavigationController + homeNavigationController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HomeNavigationController") as! UINavigationController // 从 StoryBoard 初始化而来的 Navigation Controller 会自动初始化他的 Root View Controller,即 HomeViewController // 我们将其(指针)取出,赋给容器 View Controller 的成员变量 homeViewController homeViewController = homeNavigationController.viewControllers.first as! HomeViewController // 分别将 Navigation Bar 和 homeViewController 的视图加入 TabBar Controller 的视图 - tabBarView.addSubview(homeViewController.navigationController!.view) - tabBarView.addSubview(homeViewController.view) + tabBarView?.addSubview(homeViewController.navigationController!.view) + tabBarView?.addSubview(homeViewController.view) // 在 TabBar Controller 的视图中,将 TabBar 视图提到最表层 - tabBarView.bringSubviewToFront(mainTabBarController.tabBar) + tabBarView?.bringSubview(toFront: mainTabBarController.tabBar) // 将主视图加入容器 self.view.addSubview(mainView) // 分别指定 Navigation Bar 左右两侧按钮的事件 - homeViewController.navigationItem.leftBarButtonItem?.action = Selector("showLeft") - homeViewController.navigationItem.rightBarButtonItem?.action = Selector("showRight") + homeViewController.navigationItem.leftBarButtonItem?.action = #selector(ViewController.showLeft) + homeViewController.navigationItem.rightBarButtonItem?.action = #selector(ViewController.showRight) // 给主视图绑定 UIPanGestureRecognizer let panGesture = homeViewController.panGesture - panGesture.addTarget(self, action: Selector("pan:")) - mainView.addGestureRecognizer(panGesture) + panGesture?.addTarget(self, action: #selector(ViewController.pan(_:))) + mainView.addGestureRecognizer(panGesture!) // 生成单击收起菜单手势 - tapGesture = UITapGestureRecognizer(target: self, action: "showHome") + tapGesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.showHome)) } override func didReceiveMemoryWarning() { @@ -108,13 +108,13 @@ class ViewController: UIViewController { } // 响应 UIPanGestureRecognizer 事件 - func pan(recongnizer: UIPanGestureRecognizer) { - let x = recongnizer.translationInView(self.view).x + func pan(_ recongnizer: UIPanGestureRecognizer) { + let x = recongnizer.translation(in: self.view).x let trueDistance = distance + x // 实时距离 let trueProportion = trueDistance / (Common.screenWidth*FullDistance) // 如果 UIPanGestureRecognizer 结束,则激活自动停靠 - if recongnizer.state == UIGestureRecognizerState.Ended { + if recongnizer.state == UIGestureRecognizerState.ended { if trueDistance > Common.screenWidth * (Proportion / 3) { showLeft() @@ -139,13 +139,13 @@ class ViewController: UIViewController { // 执行视差特效 blackCover.alpha = (proportion - Proportion) / (1 - Proportion) // 执行平移和缩放动画 - recongnizer.view!.center = CGPointMake(self.view.center.x + trueDistance, self.view.center.y) - recongnizer.view!.transform = CGAffineTransformScale(CGAffineTransformIdentity, proportion, proportion) + recongnizer.view!.center = CGPoint(x: self.view.center.x + trueDistance, y: self.view.center.y) + recongnizer.view!.transform = CGAffineTransform.identity.scaledBy(x: proportion, y: proportion) // 执行左视图动画 let pro = 0.8 + (proportionOfLeftView - 0.8) * trueProportion - leftViewController.view.center = CGPointMake(centerOfLeftViewAtBeginning.x + distanceOfLeftView * trueProportion, centerOfLeftViewAtBeginning.y - (proportionOfLeftView - 1) * leftViewController.view.frame.height * trueProportion / 2 ) - leftViewController.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, pro, pro) + leftViewController.view.center = CGPoint(x: centerOfLeftViewAtBeginning.x + distanceOfLeftView * trueProportion, y: centerOfLeftViewAtBeginning.y - (proportionOfLeftView - 1) * leftViewController.view.frame.height * trueProportion / 2 ) + leftViewController.view.transform = CGAffineTransform.identity.scaledBy(x: pro, y: pro) } // 封装三个方法,便于后期调用 @@ -157,7 +157,7 @@ class ViewController: UIViewController { // 计算距离,执行菜单自动滑动动画 distance = self.view.center.x * (FullDistance*2 + Proportion - 1) doTheAnimate(self.Proportion, showWhat: "left") - homeNavigationController.popToRootViewControllerAnimated(true) + homeNavigationController.popToRootViewController(animated: true) } // 展示主视图 func showHome() { @@ -176,17 +176,17 @@ class ViewController: UIViewController { doTheAnimate(self.Proportion, showWhat: "right") } // 执行三种动画:显示左侧菜单、显示主页、显示右侧菜单 - func doTheAnimate(proportion: CGFloat, showWhat: String) { - UIView.animateWithDuration(0.3, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in + func doTheAnimate(_ proportion: CGFloat, showWhat: String) { + UIView.animate(withDuration: 0.3, delay: 0, options: UIViewAnimationOptions(), animations: { () -> Void in // 移动首页中心 - self.mainView.center = CGPointMake(self.view.center.x + self.distance, self.view.center.y) + self.mainView.center = CGPoint(x: self.view.center.x + self.distance, y: self.view.center.y) // 缩放首页 - self.mainView.transform = CGAffineTransformScale(CGAffineTransformIdentity, proportion, proportion) + self.mainView.transform = CGAffineTransform.identity.scaledBy(x: proportion, y: proportion) if showWhat == "left" { // 移动左侧菜单的中心 - self.leftViewController.view.center = CGPointMake(self.centerOfLeftViewAtBeginning.x + self.distanceOfLeftView, self.leftViewController.view.center.y) + self.leftViewController.view.center = CGPoint(x: self.centerOfLeftViewAtBeginning.x + self.distanceOfLeftView, y: self.leftViewController.view.center.y) // 缩放左侧菜单 - self.leftViewController.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, self.proportionOfLeftView, self.proportionOfLeftView) + self.leftViewController.view.transform = CGAffineTransform.identity.scaledBy(x: self.proportionOfLeftView, y: self.proportionOfLeftView) } // 改变黑色遮罩层的透明度,实现视差效果 self.blackCover.alpha = showWhat == "home" ? 1 : 0 diff --git a/SwiftSideslipLikeQQTests/SwiftSideslipLikeQQTests.swift b/SwiftSideslipLikeQQTests/SwiftSideslipLikeQQTests.swift index 534bb39..79d7c0c 100644 --- a/SwiftSideslipLikeQQTests/SwiftSideslipLikeQQTests.swift +++ b/SwiftSideslipLikeQQTests/SwiftSideslipLikeQQTests.swift @@ -28,7 +28,7 @@ class SwiftSideslipLikeQQTests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock() { + self.measure() { // Put the code you want to measure the time of here. } }