From d7a3a6e7b962d920eadb43ead2f18c8db3328561 Mon Sep 17 00:00:00 2001 From: John Pope Date: Mon, 18 Apr 2016 15:21:32 -0400 Subject: [PATCH] updates for compiling to Xcode 7.3 --- Animation.xcodeproj/project.pbxproj | 7 ++++- .../contents.xcworkspacedata | 7 +++++ .../DropdownAppearTransitioning.swift | 4 +-- .../DropdownDismissTransitioning.swift | 4 +-- .../DropdownExampleViewController.swift | 14 +++++----- .../Dropdown/DropdownViewController.swift | 4 +-- Animation/ExampleNobelViewController.swift | 12 ++++----- Animation/Info.plist | 2 +- Animation/LayoutConstraintAnimator.swift | 20 +++++++------- Animation/MainNavigationViewController.swift | 2 +- Animation/MainViewController.swift | 6 ++--- .../Modal/ModalAppearTransitioning.swift | 4 +-- .../Modal/ModalDismissTransitioning.swift | 4 +-- .../Modal/ModalExampleViewController.swift | 2 +- Animation/Modal/ModalViewController.swift | 10 +++---- .../Search/SearchExampleViewController.swift | 14 +++++----- Animation/TabBar/TabBarController.swift | 26 +++++++++---------- .../TabBarExampleAnimatedTransitioning.swift | 8 +++--- .../TabBar/TabBarPeopleViewController.swift | 2 +- 19 files changed, 82 insertions(+), 70 deletions(-) create mode 100644 Animation.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/Animation.xcodeproj/project.pbxproj b/Animation.xcodeproj/project.pbxproj index 6099f42..39f735b 100644 --- a/Animation.xcodeproj/project.pbxproj +++ b/Animation.xcodeproj/project.pbxproj @@ -301,7 +301,9 @@ 80C472FE19DDC6C2008274C0 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0600; + LastSwiftMigration = 0730; + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0730; ORGANIZATIONNAME = IBM; TargetAttributes = { 80C4730519DDC6C2008274C0 = { @@ -447,6 +449,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -527,6 +530,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.example.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = Animation; PROVISIONING_PROFILE = ""; TARGETED_DEVICE_FAMILY = 1; @@ -552,6 +556,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.example.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = Animation; PROVISIONING_PROFILE = ""; TARGETED_DEVICE_FAMILY = 1; diff --git a/Animation.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Animation.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Animation.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Animation/Dropdown/DropdownAppearTransitioning.swift b/Animation/Dropdown/DropdownAppearTransitioning.swift index 1492dd8..cceffb2 100644 --- a/Animation/Dropdown/DropdownAppearTransitioning.swift +++ b/Animation/Dropdown/DropdownAppearTransitioning.swift @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac class DropdownAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.8 } @@ -19,7 +19,7 @@ class DropdownAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioni let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.addSubview(to.view) + container!.addSubview(to.view) to.show() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) diff --git a/Animation/Dropdown/DropdownDismissTransitioning.swift b/Animation/Dropdown/DropdownDismissTransitioning.swift index 2726792..804dc93 100644 --- a/Animation/Dropdown/DropdownDismissTransitioning.swift +++ b/Animation/Dropdown/DropdownDismissTransitioning.swift @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac class DropdownDismissTransitioning: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.8 } @@ -20,7 +20,7 @@ class DropdownDismissTransitioning: NSObject, UIViewControllerAnimatedTransition let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.insertSubview(to.view, atIndex: 0) + container!.insertSubview(to.view, atIndex: 0) from.hide() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) diff --git a/Animation/Dropdown/DropdownExampleViewController.swift b/Animation/Dropdown/DropdownExampleViewController.swift index 4354e56..0d5a623 100644 --- a/Animation/Dropdown/DropdownExampleViewController.swift +++ b/Animation/Dropdown/DropdownExampleViewController.swift @@ -44,7 +44,7 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon UIImage(named: "circle_x_06")!, UIImage(named: "circle_x_07")! ]; - var reversedAnimationImages: [UIImage] { get { return reverse(animationImages) } } + var reversedAnimationImages: [UIImage] { get { return Array(animationImages.reverse()) } } var hiddenStatusBar:Bool = false { didSet { @@ -89,16 +89,16 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon func show(completion: () -> Void) { dropdownButtonImage.animationImages = self.animationImages; - dropdownButtonImage.image = dropdownButtonImage.animationImages?.last as? UIImage + dropdownButtonImage.image = dropdownButtonImage.animationImages?.last dropdownButtonImage.startAnimating() let delay = dropdownButtonImage.animationDuration * Double(NSEC_PER_SEC) - var time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) + let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) dispatch_after(time, dispatch_get_main_queue(), { () -> Void in self.dropdownButtonImage.stopAnimating() }) - var animationDuration = Double(self.animationMultiplier) * 1 / 2.5; + let animationDuration = Double(self.animationMultiplier) * 1 / 2.5; UIView.animateWithDuration(animationDuration, animations: { () -> Void in self.backgroundView.alpha = 1 @@ -108,16 +108,16 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon func hide(completion: () -> Void ) { dropdownButtonImage.animationImages = self.reversedAnimationImages - dropdownButtonImage.image = dropdownButtonImage.animationImages?.last as? UIImage + dropdownButtonImage.image = dropdownButtonImage.animationImages?.last dropdownButtonImage.startAnimating() let delay = dropdownButtonImage.animationDuration * Double(NSEC_PER_SEC) - var time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) + let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) dispatch_after(time, dispatch_get_main_queue(), { () -> Void in self.dropdownButtonImage.stopAnimating() }) - var animationDuration = Double(self.animationMultiplier) * 1 / 2.5; + let animationDuration = Double(self.animationMultiplier) * 1 / 2.5; UIView.animateWithDuration(animationDuration, animations: { () -> Void in self.backgroundView.alpha = 0 diff --git a/Animation/Dropdown/DropdownViewController.swift b/Animation/Dropdown/DropdownViewController.swift index 2d94173..6972098 100644 --- a/Animation/Dropdown/DropdownViewController.swift +++ b/Animation/Dropdown/DropdownViewController.swift @@ -57,7 +57,7 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi ]; var delegate:DropDownViewControllerDelegate? - var reversedAnimationImages: [UIImage] { get { return reverse(animationImages) } } + var reversedAnimationImages: [UIImage] { get { return Array(animationImages.reverse()) } } var tableHeight: CGFloat { get { return CGFloat(cellHeight * numberOfCells) } } var dropdownPressed: ((index: Int) -> Void)? var isOpen = false @@ -126,7 +126,7 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - var cell = tableView.dequeueReusableCellWithIdentifier("DropdownOptionCell") as! DropdownOptionCell + let cell = tableView.dequeueReusableCellWithIdentifier("DropdownOptionCell") as! DropdownOptionCell cell.label.text = "Option \(indexPath.row + 1)" diff --git a/Animation/ExampleNobelViewController.swift b/Animation/ExampleNobelViewController.swift index 16e2463..34da56e 100644 --- a/Animation/ExampleNobelViewController.swift +++ b/Animation/ExampleNobelViewController.swift @@ -39,14 +39,14 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab var error:NSError? let path1 = bundle.pathForResource("nobels_alphabetically", ofType: "json") - var data1:NSData = NSData(contentsOfFile: path1!)! - let json1:AnyObject = NSJSONSerialization.JSONObjectWithData(data1, options: NSJSONReadingOptions.AllowFragments, error:&error)! + let data1:NSData = NSData(contentsOfFile: path1!)! + let json1:AnyObject = try! NSJSONSerialization.JSONObjectWithData(data1, options: NSJSONReadingOptions.AllowFragments) nobelsAlphabetically = json1 as? NSArray let path2 = bundle.pathForResource("nobels_by_discipline", ofType: "json") - var data2:NSData = NSData(contentsOfFile: path2!)! - let json2:AnyObject = NSJSONSerialization.JSONObjectWithData(data2, options: NSJSONReadingOptions.AllowFragments, error:&error)! + let data2:NSData = NSData(contentsOfFile: path2!)! + let json2:AnyObject = try! NSJSONSerialization.JSONObjectWithData(data2, options: NSJSONReadingOptions.AllowFragments) nobelsByDiscipline = json2 as? NSArray @@ -79,11 +79,11 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab let array = section["Data"] as? NSArray - var nobel_dict = NSMutableDictionary() + let nobel_dict = NSMutableDictionary() nobel_dict["Section"] = section["Section"] - var nobel_array = NSMutableArray() + let nobel_array = NSMutableArray() if let array = array { diff --git a/Animation/Info.plist b/Animation/Info.plist index d7bc0b1..c5e1a9f 100644 --- a/Animation/Info.plist +++ b/Animation/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.example.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Animation/LayoutConstraintAnimator.swift b/Animation/LayoutConstraintAnimator.swift index 1c06e3b..89937e6 100644 --- a/Animation/LayoutConstraintAnimator.swift +++ b/Animation/LayoutConstraintAnimator.swift @@ -45,12 +45,12 @@ class LayoutConstraintAnimator: NSObject { The constructor for the animation. Once the animation is created, it is not able to be modified or stopped. - :param: constraints The set of constraints to be animated - :param: delay The delay, in seconds, before beginning the animation - :param: duration The duration, in seconds, of the animation to be performed - :param: toConstants The values of the constants to be set on each of the constraints - :param: easing The easing algorithm to be used when calculating the target's values - :param: completion The block to be performed on completion of the animation + - parameter constraints: The set of constraints to be animated + - parameter delay: The delay, in seconds, before beginning the animation + - parameter duration: The duration, in seconds, of the animation to be performed + - parameter toConstants: The values of the constants to be set on each of the constraints + - parameter easing: The easing algorithm to be used when calculating the target's values + - parameter completion: The block to be performed on completion of the animation */ required init(constraints: [NSLayoutConstraint], delay:NSTimeInterval, duration:NSTimeInterval, toConstants:[CGFloat], easing: LayoutConstraintEasing, @@ -87,11 +87,11 @@ class LayoutConstraintAnimator: NSObject { } } - var time = CGFloat((CACurrentMediaTime() - startTime) / duration) + let time = CGFloat((CACurrentMediaTime() - startTime) / duration) // check to see if the animation has completed if time >= 1 { - for (index, constraint) in enumerate(constraints) { + for (index, constraint) in constraints.enumerate() { constraint.constant = toConstants[index] } @@ -106,9 +106,9 @@ class LayoutConstraintAnimator: NSObject { } // process the animation - var t = easing.valueFor(CGFloat(time)) + let t = easing.valueFor(CGFloat(time)) - for (index, constraint) in enumerate(constraints) { + for (index, constraint) in constraints.enumerate() { constraint.constant = (1 - t) * fromConstants[index] + t * toConstants[index] } } diff --git a/Animation/MainNavigationViewController.swift b/Animation/MainNavigationViewController.swift index 1aa4446..a5bd152 100644 --- a/Animation/MainNavigationViewController.swift +++ b/Animation/MainNavigationViewController.swift @@ -20,7 +20,7 @@ class MainNavigationViewController: UINavigationController { // Create a long press recognizer that requires two fingers and reverts the navigation back to the // main menu. - var longPressRecognizer = UILongPressGestureRecognizer(target: self, action: Selector("longPress:")) + let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: Selector("longPress:")) longPressRecognizer.numberOfTouchesRequired = 2 view.addGestureRecognizer(longPressRecognizer) } diff --git a/Animation/MainViewController.swift b/Animation/MainViewController.swift index 9cbe8d1..82249f7 100644 --- a/Animation/MainViewController.swift +++ b/Animation/MainViewController.swift @@ -111,12 +111,12 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat // navigation controller. func showView(storyboard: String, viewControllerID: String) { let sb = UIStoryboard(name: storyboard, bundle: nil) - let vc = sb.instantiateViewControllerWithIdentifier(viewControllerID) as! UIViewController + let vc = sb.instantiateViewControllerWithIdentifier(viewControllerID) if vc is UINavigationController { var nav = vc as! UINavigationController - var view = nav.viewControllers.first as! UIViewController - self.navigationController?.pushViewController(view, animated: true) + var view = nav.viewControllers.first + self.navigationController?.pushViewController(view!, animated: true) } else { self.navigationController?.pushViewController(vc, animated: true) } diff --git a/Animation/Modal/ModalAppearTransitioning.swift b/Animation/Modal/ModalAppearTransitioning.swift index 206da82..f534b5f 100644 --- a/Animation/Modal/ModalAppearTransitioning.swift +++ b/Animation/Modal/ModalAppearTransitioning.swift @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac class ModalAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.8 } @@ -19,7 +19,7 @@ class ModalAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioning let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.addSubview(to.view) + container!.addSubview(to.view) to.show() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) diff --git a/Animation/Modal/ModalDismissTransitioning.swift b/Animation/Modal/ModalDismissTransitioning.swift index 33b9d7a..3e65c09 100644 --- a/Animation/Modal/ModalDismissTransitioning.swift +++ b/Animation/Modal/ModalDismissTransitioning.swift @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac class ModalDismissTransitioning: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.8 } @@ -20,7 +20,7 @@ class ModalDismissTransitioning: NSObject, UIViewControllerAnimatedTransitioning let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.insertSubview(to.view, atIndex: 0) + container!.insertSubview(to.view, atIndex: 0) from.hide() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) diff --git a/Animation/Modal/ModalExampleViewController.swift b/Animation/Modal/ModalExampleViewController.swift index 2439b51..0327ed1 100644 --- a/Animation/Modal/ModalExampleViewController.swift +++ b/Animation/Modal/ModalExampleViewController.swift @@ -35,7 +35,7 @@ class ModalExampleViewController: ExampleNobelViewController { // MARK: - Lifecycle override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { - var modalVC = segue.destinationViewController as! ModalViewController + let modalVC = segue.destinationViewController as! ModalViewController modalVC.modalPresentationStyle = .Custom modalVC.transitioningDelegate = modalTransitioningDelegate diff --git a/Animation/Modal/ModalViewController.swift b/Animation/Modal/ModalViewController.swift index f186be6..14ccf67 100644 --- a/Animation/Modal/ModalViewController.swift +++ b/Animation/Modal/ModalViewController.swift @@ -54,7 +54,7 @@ class ModalViewController: UIViewController, UITableViewDelegate { loader.animationImages = [UIImage]() for var index = 100; index < 147; index++ { - var frameName = String(format: "Loader_00%03d", index) + let frameName = String(format: "Loader_00%03d", index) loader.animationImages?.append(UIImage(named:frameName)!) } @@ -136,16 +136,16 @@ class ModalViewController: UIViewController, UITableViewDelegate { // display PDF // first string value is pdf file name var pdfLoc = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource("Bee", ofType:"pdf")!) - var request = NSURLRequest(URL: pdfLoc!); + var request = NSURLRequest(URL: pdfLoc); self.pdfView.loadRequest(request); self.pdfView.alpha = 0 self.pdfView.transform = CGAffineTransformMakeScale(0.75, 0.75) // show PDF - UIView.animateWithDuration(animationDuration, delay: 1.5, options: nil, animations: { () -> Void in + UIView.animateWithDuration(animationDuration, delay: 1.5, options: [], animations: { () -> Void in self.loader.alpha = 0 // fade out loader }, completion: { finished in - UIView.animateWithDuration(0.25, delay: 0, options: nil, animations: { () -> Void in + UIView.animateWithDuration(0.25, delay: 0, options: [], animations: { () -> Void in // fade in PDF self.loaderBG.alpha = 0 self.pdfView.alpha = 1 @@ -162,7 +162,7 @@ class ModalViewController: UIViewController, UITableViewDelegate { func hide(completion: () -> Void ) { - var animationDuration = Double(self.animationMultiplier) * 1 / 4.0; + let animationDuration = Double(self.animationMultiplier) * 1 / 4.0; self.view.layoutIfNeeded() diff --git a/Animation/Search/SearchExampleViewController.swift b/Animation/Search/SearchExampleViewController.swift index f6dd3ce..d52bcf2 100644 --- a/Animation/Search/SearchExampleViewController.swift +++ b/Animation/Search/SearchExampleViewController.swift @@ -82,7 +82,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega // grabs the animation frames from the bundle for var index = 100; index < 147; index++ { - var frameName = String(format: "Loader_00%03d", index) + let frameName = String(format: "Loader_00%03d", index) loader.animationImages?.append(UIImage(named:frameName)!) } @@ -120,7 +120,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega /** * Performs all of the animations necessary to display the search results * - * :param: results The string to display as the search result + * - parameter results: The string to display as the search result */ func showResults(results: String) { resultsLabel.text = results @@ -179,7 +179,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega let animationDelay: NSTimeInterval = 0 UIView.animateWithDuration(animationDuration, delay: animationDelay, - options: nil, animations: { () -> Void in + options: [], animations: { () -> Void in self.itemsView.alpha = 1.0 self.tableView.alpha = 1.0 }, completion: nil) @@ -243,21 +243,21 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega // MARK: - Text Field func textChanged() -> Void { - self.xButton.hidden = count(self.searchField.text) == 0 + self.xButton.hidden = self.searchField.text!.characters.count == 0 } func textFieldDidBeginEditing(textField: UITextField) { self.collapseHeader() - self.xButton.hidden = count(textField.text) == 0 + self.xButton.hidden = textField.text!.characters.count == 0 } func textFieldShouldReturn(textField: UITextField) -> Bool { - if count(textField.text) < 2 { + if textField.text!.characters.count < 2 { return false } - search(textField.text) + search(textField.text!) return true } diff --git a/Animation/TabBar/TabBarController.swift b/Animation/TabBar/TabBarController.swift index f54b5cb..4c5b0f0 100644 --- a/Animation/TabBar/TabBarController.swift +++ b/Animation/TabBar/TabBarController.swift @@ -46,16 +46,16 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate { tabBar.frame = rect // set the default and selected icon for each tab bar item - (self.tabBar.items?[0] as! UITabBarItem).image = UIImage(named: "dashboard_green")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) - (self.tabBar.items?[0] as! UITabBarItem).selectedImage = UIImage(named: "dashboard_white")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) - (self.tabBar.items?[1] as! UITabBarItem).image = UIImage(named: "stats_green")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) - (self.tabBar.items?[1] as! UITabBarItem).selectedImage = UIImage(named: "stats_white")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) - (self.tabBar.items?[2] as! UITabBarItem).image = UIImage(named: "contacts_green")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) - (self.tabBar.items?[2] as! UITabBarItem).selectedImage = UIImage(named: "contacts_white")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + ((self.tabBar.items?[0])! as UITabBarItem).image = UIImage(named: "dashboard_green")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + ((self.tabBar.items?[0])! as UITabBarItem).selectedImage = UIImage(named: "dashboard_white")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + ((self.tabBar.items?[1])! as UITabBarItem).image = UIImage(named: "stats_green")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + ((self.tabBar.items?[1])! as UITabBarItem).selectedImage = UIImage(named: "stats_white")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + ((self.tabBar.items?[2])! as UITabBarItem).image = UIImage(named: "contacts_green")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + ((self.tabBar.items?[2])! as UITabBarItem).selectedImage = UIImage(named: "contacts_white")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) let indicatorContainerView = UIView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 60)) indicatorContainerView.backgroundColor = MotionStyleKit.motion_Color - indicatorContainerView.setTranslatesAutoresizingMaskIntoConstraints(false) + indicatorContainerView.translatesAutoresizingMaskIntoConstraints = false view.sendSubviewToBack(indicatorContainerView) view.addSubview(indicatorContainerView) @@ -94,7 +94,7 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate { // MARK: - Tab Bar - override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) { + override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) { if item == previousItem { return @@ -102,7 +102,7 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate { if let iv1 = self.indicatorView1 { if item == tabBar.items![0] as? UITabBarItem || previousItem == tabBar.items![0] as? UITabBarItem { - var translation: CGFloat = item == tabBar.items![0] as! UITabBarItem ? 0 : 60.0 + let translation: CGFloat = item == tabBar.items![0] ? 0 : 60.0 iv1.layer.transform = CATransform3DMakeTranslation(0, 60.0 - translation, 0) ViewAnimator.animateView(iv1, withDuration: 0.4, andEasingFunction: LayoutConstraintEasing.EaseInMTF, toTransform: CATransform3DMakeTranslation(0.0, translation, 0.0)) } @@ -110,7 +110,7 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate { if let iv2 = self.indicatorView2 { if item == tabBar.items![1] as? UITabBarItem || previousItem == tabBar.items![1] as? UITabBarItem { - let translation: CGFloat = item == tabBar.items![1] as! UITabBarItem ? 0 : 60.0 + let translation: CGFloat = item == tabBar.items![1] ? 0 : 60.0 iv2.layer.transform = CATransform3DMakeTranslation(0, 60.0 - translation, 0) ViewAnimator.animateView(iv2, withDuration: 0.4, andEasingFunction: LayoutConstraintEasing.EaseInMTF, toTransform: CATransform3DMakeTranslation(0.0, translation, 0.0)) } @@ -119,7 +119,7 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate { if let iv3 = self.indicatorView3 { if item == tabBar.items![2] as? UITabBarItem || previousItem == tabBar.items![2] as? UITabBarItem { - let translation: CGFloat = item == tabBar.items![2] as! UITabBarItem ? 0 : 60.0 + let translation: CGFloat = item == tabBar.items![2] ? 0 : 60.0 iv3.layer.transform = CATransform3DMakeTranslation(0, 60.0 - translation, 0) ViewAnimator.animateView(iv3, withDuration: 0.4, andEasingFunction: LayoutConstraintEasing.EaseInMTF, toTransform: CATransform3DMakeTranslation(0.0, translation, 0.0)) } @@ -135,10 +135,10 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate { for index in 0...viewControllers!.count - 1 { - if viewControllers![index] as! UIViewController == fromVC { + if viewControllers![index] == fromVC { fromIndex = index } - if viewControllers![index] as! UIViewController == toVC { + if viewControllers![index] == toVC { toIndex = index } } diff --git a/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift b/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift index 114194d..7cfe140 100644 --- a/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift +++ b/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift @@ -21,7 +21,7 @@ class TabBarExampleAnimatedTransitioning: NSObject, UIViewControllerAnimatedTran super.init() } - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.4 } @@ -33,7 +33,7 @@ class TabBarExampleAnimatedTransitioning: NSObject, UIViewControllerAnimatedTran let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.addSubview(to.view) + container!.addSubview(to.view) var direction = toIndex > fromIndex ? CGFloat(-1) : CGFloat(1) @@ -41,13 +41,13 @@ class TabBarExampleAnimatedTransitioning: NSObject, UIViewControllerAnimatedTran to.view.transform = CGAffineTransformMakeTranslation(0, to.view.bounds.height) } else if let fromPeople = from as? TabBarPeopleViewController { to.view.alpha = 1.0 - container.addSubview(from.view) + container!.addSubview(from.view) } else { from.view.alpha = 1.0 to.view.alpha = 0.0 } - UIView.animateWithDuration(animMultiplier * transitionDuration(transitionContext), delay: animMultiplier * 0.0, options: nil, animations: { () -> Void in + UIView.animateWithDuration(animMultiplier * transitionDuration(transitionContext), delay: animMultiplier * 0.0, options: [], animations: { () -> Void in to.view.alpha = 1.0 to.view.transform = CGAffineTransformIdentity diff --git a/Animation/TabBar/TabBarPeopleViewController.swift b/Animation/TabBar/TabBarPeopleViewController.swift index 250f690..3de4cc7 100644 --- a/Animation/TabBar/TabBarPeopleViewController.swift +++ b/Animation/TabBar/TabBarPeopleViewController.swift @@ -16,7 +16,7 @@ class TabBarPeopleViewController: ExampleNobelViewController { override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - var cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath) as! TableViewCell + let cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath) as! TableViewCell cell.smallLabel.text = ""