diff --git a/Animation.xcodeproj/project.pbxproj b/Animation.xcodeproj/project.pbxproj
index 6099f42..25ce259 100644
--- a/Animation.xcodeproj/project.pbxproj
+++ b/Animation.xcodeproj/project.pbxproj
@@ -461,7 +461,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -499,7 +499,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
PROVISIONING_PROFILE = "2dcdcae7-9a9f-4d6c-b29b-03baf133e47d";
SDKROOT = iphoneos;
@@ -524,11 +524,12 @@
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = Animation/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 8.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Animation;
PROVISIONING_PROFILE = "";
+ SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
@@ -549,11 +550,12 @@
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = Animation/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 8.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Animation;
PROVISIONING_PROFILE = "";
+ SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
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/Base.lproj/Main.storyboard b/Animation/Base.lproj/Main.storyboard
index 62baa94..b1ccc8f 100644
--- a/Animation/Base.lproj/Main.storyboard
+++ b/Animation/Base.lproj/Main.storyboard
@@ -1,9 +1,21 @@
-
-
+
+
+
+
+
-
+
+
+
+
+ HelveticaNeue-Bold
+
+
+ HelveticaNeue-Light
+
+
@@ -17,7 +29,7 @@
-
+
@@ -45,16 +57,16 @@
-
+
-
+
-
+
-
+
@@ -129,7 +141,6 @@
-
@@ -146,7 +157,6 @@
-
diff --git a/Animation/CubicBezier.swift b/Animation/CubicBezier.swift
index fe27d96..1265592 100644
--- a/Animation/CubicBezier.swift
+++ b/Animation/CubicBezier.swift
@@ -12,10 +12,10 @@ class CubicBezier: NSObject {
init(x1: CGFloat, y1: CGFloat, x2: CGFloat, y2: CGFloat) {
- let normalizedPoint = CGPointZero;
+ _ = CGPoint.zero;
- var p1 = CGPointZero
- var p2 = CGPointZero
+ var p1 = CGPoint.zero
+ var p2 = CGPoint.zero
// Clamp to interval [0..1]
p1.x = max(0.0, min(1.0, x1))
@@ -37,8 +37,8 @@ class CubicBezier: NSObject {
func valueForX(x: CGFloat) -> CGFloat {
let epsilon: CGFloat = 1.0 / 200.0
- let xSolved = solveCurveX(x, epsilon: epsilon)
- let y = sampleCurveY(xSolved)
+ let xSolved = solveCurveX(x: x, epsilon: epsilon)
+ let y = sampleCurveY(t: xSolved)
return y;
}
@@ -46,15 +46,16 @@ class CubicBezier: NSObject {
var t0: CGFloat, t1: CGFloat, t2: CGFloat, x2: CGFloat, d2: CGFloat
- var i: Int = 0;
+ var _: Int = 0;
// First try a few iterations of Newton's method -- normally very fast.
- for (t2 = x, i = 0; i < 8; i++) {
- x2 = sampleCurveX(t2) - x
+ t2 = x
+ for _ in 0..<8 {
+ x2 = sampleCurveX(t: t2) - x
if (fabs(x2) < epsilon) {
return t2;
}
- d2 = sampleCurveDerivativeX(t2)
+ d2 = sampleCurveDerivativeX(t: t2)
if (fabs(d2) < 1e-6) {
break;
}
@@ -74,7 +75,7 @@ class CubicBezier: NSObject {
}
while (t0 < t1) {
- x2 = sampleCurveX(t2)
+ x2 = sampleCurveX(t: t2)
if (fabs(x2 - x) < epsilon) {
return t2;
}
diff --git a/Animation/Dropdown/DropdownAppearTransitioning.swift b/Animation/Dropdown/DropdownAppearTransitioning.swift
index 1492dd8..ae261d9 100644
--- a/Animation/Dropdown/DropdownAppearTransitioning.swift
+++ b/Animation/Dropdown/DropdownAppearTransitioning.swift
@@ -8,21 +8,21 @@ 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(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.8
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
- let to = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as! DropdownViewController
+ let to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as! DropdownViewController
- let container = transitionContext.containerView()
- let duration = transitionDuration(transitionContext)
+ let container = transitionContext.containerView
+ _ = transitionDuration(using: transitionContext)
container.addSubview(to.view)
to.show() {
- transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
diff --git a/Animation/Dropdown/DropdownDismissTransitioning.swift b/Animation/Dropdown/DropdownDismissTransitioning.swift
index 2726792..4634ef3 100644
--- a/Animation/Dropdown/DropdownDismissTransitioning.swift
+++ b/Animation/Dropdown/DropdownDismissTransitioning.swift
@@ -8,28 +8,28 @@ 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(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.8
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
- let to = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- let from = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as! DropdownViewController
+ let to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ let from = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as! DropdownViewController
- let container = transitionContext.containerView()
- let duration = transitionDuration(transitionContext)
+ let container = transitionContext.containerView
+ _ = transitionDuration(using: transitionContext)
- container.insertSubview(to.view, atIndex: 0)
+ container.insertSubview(to.view, at: 0)
from.hide() {
- transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
// Because the From View Controller disappears using UIViewControllerContextTransitioning,
// re-add the toViewController's view as a subview of the key window's.
// This is a solution for an iOS 8 bug. For details, see:
// http://stackoverflow.com/questions/24338700/from-view-controller-disappears-using-uiviewcontrollercontexttransitioning
- UIApplication.sharedApplication().keyWindow!.addSubview(to.view)
+ UIApplication.shared.keyWindow!.addSubview(to.view)
}
}
diff --git a/Animation/Dropdown/DropdownExampleViewController.swift b/Animation/Dropdown/DropdownExampleViewController.swift
index 4354e56..4fee570 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 animationImages.reversed() } }
var hiddenStatusBar:Bool = false {
didSet {
@@ -65,12 +65,12 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon
dropdownButtonImage.animationDuration = Double(self.animationImages.count) / 50.0;
dropdownButtonImage.animationRepeatCount = 1;
}
-
- override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- dropdownVC = segue.destinationViewController as! DropdownViewController
+ dropdownVC = segue.destination as! DropdownViewController
- dropdownVC.modalPresentationStyle = .Custom
+ dropdownVC.modalPresentationStyle = .custom
dropdownVC.transitioningDelegate = dropdownTransitioningDelegate
dropdownVC.dropdownPressed = {(index: Int) -> Void in
@@ -80,7 +80,7 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon
hiddenStatusBar = false
if segue.identifier == "embedSegue" {
- let childViewController = segue.destinationViewController as! DropdownViewController
+ let childViewController = segue.destination as! DropdownViewController
childViewController.delegate = self
}
}
@@ -89,18 +89,18 @@ 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))
- dispatch_after(time, dispatch_get_main_queue(), { () -> Void in
+ let time = DispatchTime.now() + delay
+ DispatchQueue.main.asyncAfter(deadline: time, execute: { () -> 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
+ UIView.animate(withDuration: animationDuration, animations: { () -> Void in
self.backgroundView.alpha = 1
})
@@ -108,18 +108,18 @@ 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))
- dispatch_after(time, dispatch_get_main_queue(), { () -> Void in
+ let time = DispatchTime.now() + delay
+ DispatchQueue.main.asyncAfter(deadline: time, execute: { () -> 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
+ UIView.animate(withDuration: animationDuration, animations: { () -> Void in
self.backgroundView.alpha = 0
})
@@ -127,19 +127,19 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon
// MARK: - Actions
- @IBAction func buttonAction(sender: AnyObject) {
+ @IBAction func buttonAction(_ sender: AnyObject) {
dropdownVC.toggle()
self.toggle()
}
func toggle() {
if (isOpen) {
- hide { () -> () in
+ hide {
false
}
isOpen = false
} else {
- show { () -> () in
+ show {
false
}
isOpen = true
@@ -154,16 +154,16 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon
// MARK: - Appearance
- override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
- return UIStatusBarAnimation.Fade
+ override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
+ return UIStatusBarAnimation.fade
}
- override func prefersStatusBarHidden() -> Bool {
+ override var prefersStatusBarHidden: Bool {
return hiddenStatusBar
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return UIStatusBarStyle.LightContent
+ override var preferredStatusBarStyle: UIStatusBarStyle {
+ return UIStatusBarStyle.lightContent
}
diff --git a/Animation/Dropdown/DropdownViewController.swift b/Animation/Dropdown/DropdownViewController.swift
index 2d94173..93aca2e 100644
--- a/Animation/Dropdown/DropdownViewController.swift
+++ b/Animation/Dropdown/DropdownViewController.swift
@@ -57,9 +57,9 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi
];
var delegate:DropDownViewControllerDelegate?
- var reversedAnimationImages: [UIImage] { get { return reverse(animationImages) } }
+ var reversedAnimationImages: [UIImage] { get { return animationImages.reversed() } }
var tableHeight: CGFloat { get { return CGFloat(cellHeight * numberOfCells) } }
- var dropdownPressed: ((index: Int) -> Void)?
+ var dropdownPressed: ((_ index: Int) -> Void)?
var isOpen = false
// MARK: - Lifecycle
@@ -67,9 +67,9 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi
override func viewDidLoad() {
super.viewDidLoad()
- menuBackgroundWidth.constant = UIScreen.mainScreen().bounds.size.width
- optionsTop.constant = -UIScreen.mainScreen().bounds.size.height
- optionsBottom.constant = UIScreen.mainScreen().bounds.size.height
+ menuBackgroundWidth.constant = UIScreen.main.bounds.size.width
+ optionsTop.constant = -UIScreen.main.bounds.size.height
+ optionsBottom.constant = UIScreen.main.bounds.size.height
}
@@ -79,18 +79,18 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi
let animationDuration = Double(self.animationMultiplier) * 1 / 2.5
var dropdownBottom: CGFloat
- if tableHeight < UIScreen.mainScreen().bounds.size.height {
+ if tableHeight < UIScreen.main.bounds.size.height {
dropdownBottom =
- UIScreen.mainScreen().bounds.size.height - tableHeight - separatorView.bounds.height
+ UIScreen.main.bounds.size.height - tableHeight - separatorView.bounds.height
} else {
dropdownBottom = 10
}
let easing = LayoutConstraintEasing.Bezier(x1: 0.5, y1: 0.08, x2: 0.0, y2: 1.0)
- LayoutConstraintAnimator(constraint: self.optionsTop, delay: 0,
+ _ = LayoutConstraintAnimator(constraint: self.optionsTop, delay: 0,
duration: animationDuration, toConstant: CGFloat(0), easing: easing,
completion: nil)
- LayoutConstraintAnimator(constraint: self.optionsBottom, delay: 0,
+ _ = LayoutConstraintAnimator(constraint: self.optionsBottom, delay: 0,
duration: animationDuration, toConstant: dropdownBottom,
easing: easing, completion: nil)
}
@@ -98,21 +98,21 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi
func hide(completion: (() -> Void)?) {
let animationDuration = Double(self.animationMultiplier) * 1 / 2.5
let easing = LayoutConstraintEasing.Bezier(x1: 0.5, y1: 0.08, x2: 0.0, y2: 1.0)
- let constant = UIScreen.mainScreen().bounds.size.height
+ let constant = UIScreen.main.bounds.size.height
- LayoutConstraintAnimator(constraint: self.optionsTop, delay: 0,
+ _ = LayoutConstraintAnimator(constraint: self.optionsTop, delay: 0,
duration: animationDuration, toConstant: -constant, easing: easing,
completion: nil)
- LayoutConstraintAnimator(constraint: self.optionsBottom, delay: 0,
+ _ = LayoutConstraintAnimator(constraint: self.optionsBottom, delay: 0,
duration: animationDuration, toConstant: constant, easing: easing,
completion: nil)
}
func toggle() {
if (isOpen) {
- self.hide(nil)
+ self.hide(completion: nil)
} else {
- self.show(nil)
+ self.show(completion: nil)
}
isOpen = !isOpen
@@ -120,13 +120,13 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi
// MARK: - Table View
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return numberOfCells
}
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- var cell = tableView.dequeueReusableCellWithIdentifier("DropdownOptionCell") as! DropdownOptionCell
+ let cell = tableView.dequeueReusableCell(withIdentifier: "DropdownOptionCell") as! DropdownOptionCell
cell.label.text = "Option \(indexPath.row + 1)"
@@ -144,15 +144,15 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi
return cell;
}
- func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
- tableView.deselectRowAtIndexPath(indexPath, animated: true)
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+ tableView.deselectRow(at: indexPath as IndexPath, animated: true)
self.toggle()
- self.delegate?.dropDownViewControllerDidPressButton(self)
+ self.delegate?.dropDownViewControllerDidPressButton(viewController: self)
}
// MARK: - Appearance
- override func prefersStatusBarHidden() -> Bool {
+ override var prefersStatusBarHidden: Bool {
return true
}
diff --git a/Animation/ExampleNobelViewController.swift b/Animation/ExampleNobelViewController.swift
index 16e2463..05851e1 100644
--- a/Animation/ExampleNobelViewController.swift
+++ b/Animation/ExampleNobelViewController.swift
@@ -20,10 +20,10 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab
// MARK: - Constants, Properties
- var nobelsAlphabetically: NSArray?
- var nobelsByDiscipline: NSArray?
- var nobels: NSArray?
- var filteredNobels: NSMutableArray?
+ var nobelsAlphabetically: [Any]?
+ var nobelsByDiscipline: [Any]?
+ var nobels: [Any]?
+ var filteredNobels: [Any]?
var filters: [Bool] = []
// MARK: - Lifecycle
@@ -35,20 +35,29 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab
}
func loadData() {
- let bundle = NSBundle.mainBundle()
- var error:NSError?
+ let bundle = Bundle.main
- 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 path1 = bundle.path(forResource: "nobels_alphabetically", ofType: "json")
+ let data1:NSData = NSData(contentsOfFile: path1!)!
+ var json1: Any = []
+ do {
+ json1 = try JSONSerialization.jsonObject(with: data1 as Data, options: JSONSerialization.ReadingOptions.allowFragments)
+ } catch {
+ print("nobels_alphabetically.json could not be read")
+ }
- nobelsAlphabetically = json1 as? NSArray
+ nobelsAlphabetically = json1 as? [Any]
- 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 path2 = bundle.path(forResource: "nobels_by_discipline", ofType: "json")
+ let data2:NSData = NSData(contentsOfFile: path2!)!
+ var json2: Any = []
+ do {
+ json2 = try JSONSerialization.jsonObject(with: data2 as Data, options: JSONSerialization.ReadingOptions.allowFragments)
+ } catch {
+ print("nobels_by_discipline could not be read")
+ }
- nobelsByDiscipline = json2 as? NSArray
+ nobelsByDiscipline = json2 as? [Any]
filters = [true, true, true, true]
@@ -69,55 +78,44 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab
func updateFilters() {
- filteredNobels = NSMutableArray()
+ filteredNobels = []
if let nobels = nobels {
-
for index in 0...nobels.count - 1 {
-
- if let section = nobels.objectAtIndex(index) as? NSDictionary {
-
- let array = section["Data"] as? NSArray
-
- var nobel_dict = NSMutableDictionary()
+ if let section = nobels[index] as? [String: Any] {
+ let array = section["Data"] as? [Any]
+ var nobel_dict: [String: Any] = [:]
nobel_dict["Section"] = section["Section"]
- var nobel_array = NSMutableArray()
-
+ var nobel_array: [Any] = []
if let array = array {
-
for nobel_index in 0...array.count - 1 {
-
let person_dict = array[nobel_index] as? NSDictionary
-
if let person_dict = person_dict {
-
let discipline = person_dict["Discipline"] as? String
if let discipline = discipline {
if filters[0] && discipline == "Chemistry" {
- nobel_array.addObject(array[nobel_index])
+ nobel_array.append(array[nobel_index])
}
else if filters[1] && discipline == "Economics" {
- nobel_array.addObject(array[nobel_index])
+ nobel_array.append(array[nobel_index])
}
else if filters[2] && discipline == "Literature" {
- nobel_array.addObject(array[nobel_index])
+ nobel_array.append(array[nobel_index])
}
else if filters[3] && discipline == "Medicine" {
- nobel_array.addObject(array[nobel_index])
+ nobel_array.append(array[nobel_index])
}
}
}
-
}
-
}
nobel_dict["Data"] = nobel_array
- filteredNobels?.addObject(nobel_dict)
+ filteredNobels?.append(nobel_dict)
}
}
@@ -136,21 +134,25 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab
}
}
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let nobels = filteredNobels {
- return (nobels[section]["Data"] as! NSArray).count
+ let nobelsInSection = nobels[section] as! [String: Any]
+ let nobelData = nobelsInSection["Data"] as! [Any]
+ return nobelData.count
} else {
return 0
}
}
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let table = tableView as! TableView
- let cell = tableView.dequeueReusableCellWithIdentifier(table.cellID, forIndexPath: indexPath) as! TableViewCell
+ let cell = tableView.dequeueReusableCell(withIdentifier: table.cellID, for: indexPath as IndexPath) as! TableViewCell
if let nobels = filteredNobels {
- let person = (nobels[indexPath.section]["Data"] as! NSArray)[indexPath.row] as? NSDictionary
- if let person = person {
+ //let person = (nobels[indexPath.section]["Data"][indexPath.row] as? NSDictionary
+ let nobelsInSection = nobels[indexPath.section] as! [String: Any]
+ let nobelData = nobelsInSection["Data"] as! [Any]
+ if let person = nobelData[indexPath.row] as? [String: Any] {
let lastName = person["Last name"] as! String
let firstName = person["First name"] as! String
@@ -162,30 +164,31 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab
}
}
- cell.selectionStyle = UITableViewCellSelectionStyle.None
+ cell.selectionStyle = UITableViewCellSelectionStyle.none
return cell
}
- func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int {
+ func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
return index
}
- func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- let cell = tableView.dequeueReusableCellWithIdentifier("TableViewHeaderCellID") as! TableViewHeaderCell
+ let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewHeaderCellID") as! TableViewHeaderCell
if let nobels = filteredNobels {
- cell.label.text = nobels[section]["Section"] as? String
+ let nobelsInSection = nobels[section] as! [String: Any]
+ cell.label.text = nobelsInSection["Section"] as? String
}
return cell
}
- func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50
}
- func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 80
}
}
diff --git a/Animation/Images.xcassets/AppIcon.appiconset/Contents.json b/Animation/Images.xcassets/AppIcon.appiconset/Contents.json
index 40bbadd..fae0dd7 100644
--- a/Animation/Images.xcassets/AppIcon.appiconset/Contents.json
+++ b/Animation/Images.xcassets/AppIcon.appiconset/Contents.json
@@ -1,5 +1,15 @@
{
"images" : [
+ {
+ "idiom" : "iphone",
+ "size" : "20x20",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "20x20",
+ "scale" : "3x"
+ },
{
"idiom" : "iphone",
"size" : "29x29",
@@ -32,6 +42,16 @@
"filename" : "Motion_icon180.png",
"scale" : "3x"
},
+ {
+ "idiom" : "ipad",
+ "size" : "20x20",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "20x20",
+ "scale" : "2x"
+ },
{
"idiom" : "ipad",
"size" : "29x29",
@@ -61,6 +81,16 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "83.5x83.5",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ios-marketing",
+ "size" : "1024x1024",
+ "scale" : "1x"
}
],
"info" : {
diff --git a/Animation/LayoutConstraintAnimator.swift b/Animation/LayoutConstraintAnimator.swift
index 1c06e3b..a84dbed 100644
--- a/Animation/LayoutConstraintAnimator.swift
+++ b/Animation/LayoutConstraintAnimator.swift
@@ -15,7 +15,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac
class LayoutConstraintAnimator: NSObject {
- internal lazy var link: CADisplayLink = CADisplayLink(target: self, selector: Selector("timer"))
+ internal lazy var link: CADisplayLink = CADisplayLink(target: self, selector: #selector(LayoutConstraintAnimator.timer))
internal var startTime: Double
internal var fromConstants: [CGFloat]
internal var delaying: Bool
@@ -31,8 +31,8 @@ class LayoutConstraintAnimator: NSObject {
Convenience constructor for the animation. Simply wraps the constraint and
toConstant in an array for the main constructor.
*/
- convenience init(constraint: NSLayoutConstraint, delay:NSTimeInterval,
- duration:NSTimeInterval, toConstant:CGFloat, easing: LayoutConstraintEasing,
+ convenience init(constraint: NSLayoutConstraint, delay:TimeInterval,
+ duration:TimeInterval, toConstant:CGFloat, easing: LayoutConstraintEasing,
completion: (() -> Void)?) {
self.init(
@@ -52,8 +52,8 @@ class LayoutConstraintAnimator: NSObject {
: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
*/
- required init(constraints: [NSLayoutConstraint], delay:NSTimeInterval,
- duration:NSTimeInterval, toConstants:[CGFloat], easing: LayoutConstraintEasing,
+ required init(constraints: [NSLayoutConstraint], delay:TimeInterval,
+ duration:TimeInterval, toConstants:[CGFloat], easing: LayoutConstraintEasing,
completion: (() -> Void)?) {
self.constraints = constraints
@@ -73,10 +73,10 @@ class LayoutConstraintAnimator: NSObject {
super.init()
- self.link.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
+ self.link.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
}
- internal func timer() {
+ @objc internal func timer() {
// checks to see if we should continue delaying or process the animation
if delaying {
if (CACurrentMediaTime() - startTime) >= delay {
@@ -87,16 +87,16 @@ 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.enumerated() {
constraint.constant = toConstants[index]
}
link.invalidate()
- link.removeFromRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
+ link.remove(from: RunLoop.main, forMode: RunLoopMode.commonModes)
if let completion = completion {
completion()
@@ -106,10 +106,10 @@ class LayoutConstraintAnimator: NSObject {
}
// process the animation
- var t = easing.valueFor(CGFloat(time))
+ let t = easing.valueFor(t: CGFloat(time))
- for (index, constraint) in enumerate(constraints) {
+ for (index, constraint) in constraints.enumerated() {
constraint.constant = (1 - t) * fromConstants[index] + t * toConstants[index]
}
}
-}
\ No newline at end of file
+}
diff --git a/Animation/LayoutConstraintEasing.swift b/Animation/LayoutConstraintEasing.swift
index 37fae8f..fdc409f 100644
--- a/Animation/LayoutConstraintEasing.swift
+++ b/Animation/LayoutConstraintEasing.swift
@@ -19,12 +19,12 @@ enum LayoutConstraintEasing {
func valueFor(t: CGFloat) -> CGFloat {
switch (self) {
- case let .Linear: return t
- case let .Bezier(x1, y1, x2, y2): return bezier(t, x1:x1, y1:y1, x2:x2, y2:y2)
+ case .Linear: return t
+ case .Bezier(let x1, let y1, let x2, let y2): return bezier(t: t, x1:x1, y1:y1, x2:x2, y2:y2)
- case let .EaseInOut: return bezier(t, x1:easeInOutControlPoints[0], y1:easeInOutControlPoints[1], x2:easeInOutControlPoints[2], y2:easeInOutControlPoints[3])
- case let .EaseIn: return bezier(t, x1:easeInOutControlPoints[1], y1:easeInOutControlPoints[0], x2:easeInOutControlPoints[2], y2:easeInOutControlPoints[3])
- case let .EaseOut: return bezier(t, x1:easeInOutControlPoints[0], y1:easeInOutControlPoints[1], x2:easeInOutControlPoints[3], y2:easeInOutControlPoints[2])
+ case .EaseInOut: return bezier(t: t, x1:easeInOutControlPoints[0], y1:easeInOutControlPoints[1], x2:easeInOutControlPoints[2], y2:easeInOutControlPoints[3])
+ case .EaseIn: return bezier(t: t, x1:easeInOutControlPoints[1], y1:easeInOutControlPoints[0], x2:easeInOutControlPoints[2], y2:easeInOutControlPoints[3])
+ case .EaseOut: return bezier(t: t, x1:easeInOutControlPoints[0], y1:easeInOutControlPoints[1], x2:easeInOutControlPoints[3], y2:easeInOutControlPoints[2])
}
}
@@ -32,13 +32,13 @@ enum LayoutConstraintEasing {
// Simple linear interpolation between two points
func lerp(a:CGPoint, b:CGPoint, t:CGFloat) -> CGPoint
{
- return CGPointMake(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);
+ return CGPoint(x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t);
}
func bezier(t: CGFloat, x1:CGFloat, y1:CGFloat, x2:CGFloat, y2:CGFloat) -> CGFloat {
let cubicBezier = CubicBezier(x1: x1, y1: y1, x2: x2, y2: y2)
- return cubicBezier.valueForX(t)
+ return cubicBezier.valueForX(x: t)
}
static var EaseInOutMTF : CAMediaTimingFunction {
@@ -59,4 +59,4 @@ enum LayoutConstraintEasing {
}
-}
\ No newline at end of file
+}
diff --git a/Animation/MainNavigationViewController.swift b/Animation/MainNavigationViewController.swift
index 1aa4446..8c8d4e3 100644
--- a/Animation/MainNavigationViewController.swift
+++ b/Animation/MainNavigationViewController.swift
@@ -15,20 +15,20 @@ class MainNavigationViewController: UINavigationController {
// MARK: - Lifecycle
- override func viewWillAppear(animated: Bool) {
+ override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// 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(MainNavigationViewController.longPress(_:)))
longPressRecognizer.numberOfTouchesRequired = 2
view.addGestureRecognizer(longPressRecognizer)
}
// MARK: - Flow
- func longPress(longPress: UILongPressGestureRecognizer) {
- popToRootViewControllerAnimated(true)
+ @objc func longPress(_ longPress: UILongPressGestureRecognizer) {
+ _ = popToRootViewController(animated: true)
}
}
diff --git a/Animation/MainViewController.swift b/Animation/MainViewController.swift
index 9cbe8d1..5499446 100644
--- a/Animation/MainViewController.swift
+++ b/Animation/MainViewController.swift
@@ -35,18 +35,18 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat
// MARK: - Scroll View
- func scrollViewDidScroll(scrollView: UIScrollView) {
+ func scrollViewDidScroll(_ scrollView: UIScrollView) {
let scrollOffset = scrollView.contentOffset.y
- let maxScrollOffset: CGFloat = 30
- let alphaPercentage = (150 - (scrollOffset * 10)) / 150 * 2
+ let _: CGFloat = 30
+ _ = (150 - (scrollOffset * 10)) / 150 * 2
if noteViewHeight == nil {
noteViewHeight = noteViewHeightConstraint.constant
}
- let offsetToShowNote: CGFloat = -20
- let offsetToHideNote: CGFloat = 15
+ let _: CGFloat = -20
+ let _: CGFloat = 15
}
// MARK: - Table View
@@ -55,7 +55,7 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat
return 1
}
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
return 4
@@ -64,9 +64,9 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat
}
}
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCellWithIdentifier("TableViewCellID") as! TableViewCell
- cell.backgroundColor = UIColor.clearColor()
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+ let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCellID") as! TableViewCell
+ cell.backgroundColor = UIColor.clear
// Display text
switch (indexPath.section, indexPath.row) {
@@ -85,24 +85,24 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat
return cell
}
- func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50
}
- func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Row selected, view storyboard by ID
switch (indexPath.section, indexPath.row) {
case (0, 0):
- showView("TabBar", viewControllerID: "TabBarControllerID")
+ showView(storyboard: "TabBar", viewControllerID: "TabBarControllerID")
case (0, 1):
- showView("Search", viewControllerID: "SearchNavigationControllerID")
+ showView(storyboard: "Search", viewControllerID: "SearchNavigationControllerID")
case (0, 2):
- showView("Modal", viewControllerID: "ModalNavigationControllerID")
+ showView(storyboard: "Modal", viewControllerID: "ModalNavigationControllerID")
case (0, 3):
- showView("Dropdown", viewControllerID: "DropdownViewControllerID")
+ showView(storyboard: "Dropdown", viewControllerID: "DropdownViewControllerID")
default:break
}
- tableView.deselectRowAtIndexPath(indexPath, animated: false)
+ tableView.deselectRow(at: indexPath as IndexPath, animated: false)
}
// MARK: - Flow
@@ -111,11 +111,11 @@ 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.instantiateViewController(withIdentifier: viewControllerID)
if vc is UINavigationController {
- var nav = vc as! UINavigationController
- var view = nav.viewControllers.first as! UIViewController
+ let nav = vc as! UINavigationController
+ let view = nav.viewControllers.first!
self.navigationController?.pushViewController(view, animated: true)
} else {
self.navigationController?.pushViewController(vc, animated: true)
@@ -125,8 +125,8 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat
// MARK: - Appearance
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return UIStatusBarStyle.LightContent
+ override var preferredStatusBarStyle: UIStatusBarStyle {
+ return UIStatusBarStyle.lightContent
}
}
diff --git a/Animation/Modal/Modal.storyboard b/Animation/Modal/Modal.storyboard
index 4038686..cf3d97f 100644
--- a/Animation/Modal/Modal.storyboard
+++ b/Animation/Modal/Modal.storyboard
@@ -1,20 +1,27 @@
-
-
+
+
+
+
+
-
+
+
+
+
+ HelveticaNeue-Light
+
+
-
-
@@ -48,7 +55,7 @@
-
+
@@ -68,7 +75,7 @@
-
+
@@ -90,25 +97,25 @@
-
+
-
+
-
@@ -774,11 +780,11 @@
-
+
-
+
@@ -790,14 +796,14 @@
-
+
-
+
-
+
@@ -819,7 +825,7 @@
-
+
@@ -838,7 +844,7 @@
-
+
@@ -849,7 +855,7 @@
-
+
@@ -867,7 +873,6 @@
-
@@ -889,7 +894,7 @@
-
+
diff --git a/Animation/Modal/ModalAppearTransitioning.swift b/Animation/Modal/ModalAppearTransitioning.swift
index 206da82..3f61a08 100644
--- a/Animation/Modal/ModalAppearTransitioning.swift
+++ b/Animation/Modal/ModalAppearTransitioning.swift
@@ -8,21 +8,21 @@ 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(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.8
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
- let to = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as! ModalViewController
+ let to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as! ModalViewController
- let container = transitionContext.containerView()
- let duration = transitionDuration(transitionContext)
+ let container = transitionContext.containerView
+ let duration = transitionDuration(using: transitionContext)
container.addSubview(to.view)
to.show() {
- transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
diff --git a/Animation/Modal/ModalDismissTransitioning.swift b/Animation/Modal/ModalDismissTransitioning.swift
index 33b9d7a..a5e0b46 100644
--- a/Animation/Modal/ModalDismissTransitioning.swift
+++ b/Animation/Modal/ModalDismissTransitioning.swift
@@ -8,28 +8,28 @@ 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(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.8
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
- let to = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- let from = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as! ModalViewController
+ let to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ let from = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as! ModalViewController
- let container = transitionContext.containerView()
- let duration = transitionDuration(transitionContext)
+ let container = transitionContext.containerView
+ _ = transitionDuration(using: transitionContext)
- container.insertSubview(to.view, atIndex: 0)
+ container.insertSubview(to.view, at: 0)
from.hide() {
- transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
// Because the From View Controller disappears using UIViewControllerContextTransitioning,
// re-add the toViewController's view as a subview of the key window's.
// This is a solution for an iOS 8 bug. For details, see:
// http://stackoverflow.com/questions/24338700/from-view-controller-disappears-using-uiviewcontrollercontexttransitioning
- UIApplication.sharedApplication().keyWindow!.addSubview(to.view)
+ UIApplication.shared.keyWindow!.addSubview(to.view)
}
}
diff --git a/Animation/Modal/ModalExampleViewController.swift b/Animation/Modal/ModalExampleViewController.swift
index 2439b51..442d46b 100644
--- a/Animation/Modal/ModalExampleViewController.swift
+++ b/Animation/Modal/ModalExampleViewController.swift
@@ -34,9 +34,9 @@ class ModalExampleViewController: ExampleNobelViewController {
// MARK: - Lifecycle
- override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
- var modalVC = segue.destinationViewController as! ModalViewController
- modalVC.modalPresentationStyle = .Custom
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+ let modalVC = segue.destination as! ModalViewController
+ modalVC.modalPresentationStyle = .custom
modalVC.transitioningDelegate = modalTransitioningDelegate
hiddenStatusBar = false
@@ -44,15 +44,15 @@ class ModalExampleViewController: ExampleNobelViewController {
// MARK: - Appearance
- override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
- return UIStatusBarAnimation.Fade
+ override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
+ return UIStatusBarAnimation.fade
}
- override func prefersStatusBarHidden() -> Bool {
+ override var prefersStatusBarHidden: Bool {
return hiddenStatusBar
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return UIStatusBarStyle.LightContent
+ override var preferredStatusBarStyle: UIStatusBarStyle {
+ return UIStatusBarStyle.lightContent
}
}
diff --git a/Animation/Modal/ModalViewController.swift b/Animation/Modal/ModalViewController.swift
index f186be6..93a2e23 100644
--- a/Animation/Modal/ModalViewController.swift
+++ b/Animation/Modal/ModalViewController.swift
@@ -36,7 +36,7 @@ class ModalViewController: UIViewController, UITableViewDelegate {
// MARK: - Constants, Properties
- var modalPressed: ((index: Int) -> Void)?
+ var modalPressed: ((_ index: Int) -> Void)?
let animationMultiplier : CGFloat = 1
let maxModalHeadHeight: CGFloat = 80
@@ -47,14 +47,14 @@ class ModalViewController: UIViewController, UITableViewDelegate {
super.viewDidLoad()
modalHeadHeight.constant = modalHead.bounds.size.height
- modalBackgroundTop.constant = UIScreen.mainScreen().bounds.size.height - 50
+ modalBackgroundTop.constant = UIScreen.main.bounds.size.height - 50
self.pdfView.alpha = 0
loader.animationImages = [UIImage]()
- for var index = 100; index < 147; index++ {
- var frameName = String(format: "Loader_00%03d", index)
+ for index in 100..<147 {
+ let frameName = String(format: "Loader_00%03d", index)
loader.animationImages?.append(UIImage(named:frameName)!)
}
@@ -67,7 +67,7 @@ class ModalViewController: UIViewController, UITableViewDelegate {
// MARK: - Scroll View
// header shrinks and its elements resize based on scroll position
- func scrollViewDidScroll(scrollView: UIScrollView) {
+ func scrollViewDidScroll(_ scrollView: UIScrollView) {
// update views based on scroll offset
let scrollOffset = scrollView.contentOffset.y
@@ -83,11 +83,11 @@ class ModalViewController: UIViewController, UITableViewDelegate {
if (scrollOffset < 0) {
// at top
// set to max position
- self.menuLabel.transform = CGAffineTransformIdentity
+ self.menuLabel.transform = CGAffineTransform.identity
self.buttonImageView.alpha = 1
- self.closeButton.enabled = true
+ self.closeButton.isEnabled = true
- UIView.animateWithDuration(0.1, animations: {
+ UIView.animate(withDuration: 0.1, animations: {
self.modalHeadHeight.constant = 80
self.view.layoutIfNeeded()
})
@@ -96,11 +96,11 @@ class ModalViewController: UIViewController, UITableViewDelegate {
// proportionally adjust the header and it's children
if scrollOffset < maxScrollOffset {
self.buttonImageView.alpha = scalePercent
- self.closeButton.enabled = true
- self.menuLabel.transform = CGAffineTransformMakeScale(labelEndPercent, labelEndPercent)
- self.buttonImageView.transform = CGAffineTransformMakeScale(labelEndPercent, labelEndPercent)
+ self.closeButton.isEnabled = true
+ self.menuLabel.transform = CGAffineTransform(scaleX: labelEndPercent, y: labelEndPercent)
+ self.buttonImageView.transform = CGAffineTransform(scaleX: labelEndPercent, y: labelEndPercent)
- UIView.animateWithDuration(0.1, animations: {
+ UIView.animate(withDuration: 0.1, animations: {
self.modalHeadHeight.constant = (80 - scrollOffset)
self.view.layoutIfNeeded()
})
@@ -108,10 +108,10 @@ class ModalViewController: UIViewController, UITableViewDelegate {
// scrolled beyond minimun
// set to min position
self.buttonImageView.alpha = 0
- self.closeButton.enabled = false
- self.menuLabel.transform = CGAffineTransformMakeScale((self.modalHead.bounds.height / maxModalHeadHeight) + 0.15, (self.modalHead.bounds.height / maxModalHeadHeight) + 0.2)
+ self.closeButton.isEnabled = false
+ self.menuLabel.transform = CGAffineTransform(scaleX: (self.modalHead.bounds.height / maxModalHeadHeight) + 0.15, y: (self.modalHead.bounds.height / maxModalHeadHeight) + 0.2)
- UIView.animateWithDuration(0.1, animations: {
+ UIView.animate(withDuration: 0.1, animations: {
self.modalHeadHeight.constant = 40
self.view.layoutIfNeeded()
})
@@ -121,35 +121,35 @@ class ModalViewController: UIViewController, UITableViewDelegate {
// MARK: - Transition Animations
- func show(completion: () -> Void ) {
+ func show(completion: @escaping () -> Void ) {
- var animationDuration = Double(self.animationMultiplier) * 1 / 3.0;
+ let animationDuration = Double(self.animationMultiplier) * 1 / 3.0;
backgroundView.alpha = 0
loaderBG.alpha = 1
loader.alpha = 1
- UIView.animateWithDuration(animationDuration, animations: { () -> Void in
+ UIView.animate(withDuration: animationDuration, animations: { () -> Void in
self.backgroundView.alpha = 1
}, completion: { finished in
// display PDF
// first string value is pdf file name
- var pdfLoc = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource("Bee", ofType:"pdf")!)
- var request = NSURLRequest(URL: pdfLoc!);
- self.pdfView.loadRequest(request);
+ let pdfLoc = NSURL(fileURLWithPath:Bundle.main.path(forResource: "Bee", ofType:"pdf")!)
+ let request = NSURLRequest(url: pdfLoc as URL);
+ self.pdfView.loadRequest(request as URLRequest);
self.pdfView.alpha = 0
- self.pdfView.transform = CGAffineTransformMakeScale(0.75, 0.75)
+ self.pdfView.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
// show PDF
- UIView.animateWithDuration(animationDuration, delay: 1.5, options: nil, animations: { () -> Void in
+ UIView.animate(withDuration: 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.animate(withDuration: 0.25, delay: 0, options: [], animations: { () -> Void in
// fade in PDF
self.loaderBG.alpha = 0
self.pdfView.alpha = 1
- self.pdfView.transform = CGAffineTransformIdentity
+ self.pdfView.transform = CGAffineTransform.identity
}, completion: { finished in
})
@@ -157,41 +157,41 @@ class ModalViewController: UIViewController, UITableViewDelegate {
})
- var timer = LayoutConstraintAnimator(constraint: self.modalBackgroundTop, delay: 0, duration: animationDuration, toConstant: CGFloat(0), easing: LayoutConstraintEasing.Bezier(x1: 0.5, y1: 0.08, x2: 0.0, y2: 1.0), completion: completion)
+ _ = LayoutConstraintAnimator(constraint: self.modalBackgroundTop, delay: 0, duration: animationDuration, toConstant: CGFloat(0), easing: LayoutConstraintEasing.Bezier(x1: 0.5, y1: 0.08, x2: 0.0, y2: 1.0), completion: completion)
}
- func hide(completion: () -> Void ) {
+ func hide(completion: @escaping () -> Void ) {
- var animationDuration = Double(self.animationMultiplier) * 1 / 4.0;
+ let animationDuration = Double(self.animationMultiplier) * 1 / 4.0;
self.view.layoutIfNeeded()
- UIView.animateWithDuration(animationDuration, animations: { () -> Void in
+ UIView.animate(withDuration: animationDuration, animations: { () -> Void in
self.backgroundView.alpha = 0
})
- var timer = LayoutConstraintAnimator(constraint: self.modalBackgroundTop, delay: 0, duration: animationDuration, toConstant: (UIScreen.mainScreen().bounds.size.height + 10), easing: LayoutConstraintEasing.Bezier(x1: 0.5, y1: 0.08, x2: 0.0, y2: 1.0)) { finished in
+ _ = LayoutConstraintAnimator(constraint: self.modalBackgroundTop, delay: 0, duration: animationDuration, toConstant: (UIScreen.main.bounds.size.height + 100), easing: LayoutConstraintEasing.Bezier(x1: 0.5, y1: 0.08, x2: 0.0, y2: 1.0)) {
- self.modalPressed?(index:0)
+ self.modalPressed?(0)
completion()
}
}
// MARK: - Actions
- @IBAction func hideAction(sender: AnyObject) {
- closeButton.hidden = true
- dismissViewControllerAnimated(true, completion: nil)
+ @IBAction func hideAction(_ sender: AnyObject) {
+ closeButton.isHidden = true
+ dismiss(animated: true, completion: nil)
}
// MARK: - Appearance
- override func prefersStatusBarHidden() -> Bool {
+ override var prefersStatusBarHidden: Bool {
return false
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return UIStatusBarStyle.LightContent
+ override var preferredStatusBarStyle: UIStatusBarStyle {
+ return UIStatusBarStyle.lightContent
}
}
diff --git a/Animation/Other/Button.swift b/Animation/Other/Button.swift
index 7ab9442..c686f03 100644
--- a/Animation/Other/Button.swift
+++ b/Animation/Other/Button.swift
@@ -10,7 +10,7 @@ class Button: UIButton {
override func awakeFromNib() {
super.awakeFromNib()
- setTitleColor(MotionStyleKit.motion_Color, forState: .Normal)
+ setTitleColor(MotionStyleKit.motion_Color, for: [])
}
}
diff --git a/Animation/Other/View.swift b/Animation/Other/View.swift
index 38290a9..420edd0 100644
--- a/Animation/Other/View.swift
+++ b/Animation/Other/View.swift
@@ -13,7 +13,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac
backgroundColor = MotionStyleKit.motion_Color
}
- override func drawRect(rect: CGRect) {
+ override func draw(_ rect: CGRect) {
let rectanglePath = UIBezierPath(rect: rect)
backgroundColor?.setFill()
rectanglePath.fill()
diff --git a/Animation/Search/Search.storyboard b/Animation/Search/Search.storyboard
index eb80aaf..83e720b 100644
--- a/Animation/Search/Search.storyboard
+++ b/Animation/Search/Search.storyboard
@@ -1,11 +1,23 @@
-
-
+
+
+
+
+
-
+
+
+
+
+ HelveticaNeue-Bold
+
+
+ HelveticaNeue-Light
+
+
@@ -29,7 +41,7 @@
-
+
@@ -47,7 +59,7 @@
-
+
@@ -59,7 +71,7 @@
-
+
@@ -75,11 +87,11 @@
-
+
-
+
@@ -89,11 +101,11 @@
-
+
-
+
@@ -125,11 +137,11 @@
-
+
-
+
@@ -139,11 +151,11 @@
-
+
-
+
@@ -175,11 +187,11 @@
-
+
-
+
@@ -189,11 +201,11 @@
-
+
-
+
@@ -225,11 +237,11 @@
-
+
-
+
@@ -239,11 +251,11 @@
-
+
-
+
@@ -275,11 +287,11 @@
-
+
-
+
@@ -289,11 +301,11 @@
-
+
-
+
@@ -325,11 +337,11 @@
-
+
-
+
@@ -339,11 +351,11 @@
-
+
-
+
@@ -445,14 +457,14 @@
-
+
-
+
@@ -477,7 +489,7 @@
-
+
@@ -486,7 +498,7 @@
-
+
@@ -502,11 +514,11 @@
-
+
-
+
@@ -516,11 +528,11 @@
-
+
-
+
@@ -541,8 +553,9 @@
+
-
+
@@ -564,25 +577,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -598,7 +611,7 @@
-
+
@@ -651,25 +664,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -685,7 +698,7 @@
-
+
@@ -719,7 +732,7 @@
-
+
@@ -773,7 +786,7 @@
-
+
@@ -818,7 +831,6 @@
-
diff --git a/Animation/Search/SearchExampleViewController.swift b/Animation/Search/SearchExampleViewController.swift
index f6dd3ce..3749c88 100644
--- a/Animation/Search/SearchExampleViewController.swift
+++ b/Animation/Search/SearchExampleViewController.swift
@@ -55,47 +55,47 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
searchFieldBackground.backgroundColor = UIColor(white: 0.957, alpha: 1)
- tableView.hidden = true
- resultsView.hidden = true
- xButton.hidden = true
+ tableView.isHidden = true
+ resultsView.isHidden = true
+ xButton.isHidden = true
self.prepareLoader()
- self.searchField.addTarget(self, action: "textChanged", forControlEvents: .EditingChanged)
+ self.searchField.addTarget(self, action: #selector(SearchExampleViewController.textChanged), for: .editingChanged)
}
- override func viewDidAppear(animated: Bool) {
+ override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
- let tapRecognizer = UITapGestureRecognizer(target: self, action: "handleSingleTap:")
+ let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(SearchExampleViewController.handleSingleTap(_:)))
tapRecognizer.numberOfTapsRequired = 1
self.view.addGestureRecognizer(tapRecognizer)
}
- override func viewWillDisappear(animated: Bool) {
+ override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
searchField.resignFirstResponder()
- NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
+ NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
}
func prepareLoader() -> Void {
loader.animationImages = [UIImage]()
// grabs the animation frames from the bundle
- for var index = 100; index < 147; index++ {
- var frameName = String(format: "Loader_00%03d", index)
+ for index in 100..<147 {
+ let frameName = String(format: "Loader_00%03d", index)
loader.animationImages?.append(UIImage(named:frameName)!)
}
loader.animationDuration = 1.5
loader.stopAnimating()
- loader.hidden = true
+ loader.isHidden = true
}
// MARK: - Actions
- @IBAction func xPressed(sender: AnyObject) {
+ @IBAction func xPressed(_ sender: AnyObject) {
self.searchField.text = ""
- self.xButton.hidden = true
+ self.xButton.isHidden = true
textFieldDidBeginEditing(searchField)
}
@@ -105,14 +105,14 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
* Starts the animation after the enter/submit button has been pressed
*/
func search(text: String) {
- showResults(text)
+ showResults(results: text)
}
/**
* Gesture recognizer which will hide the keyboard when the user clicks
* outside of the search textfield.
*/
- func handleSingleTap(recognizer: UITapGestureRecognizer) {
+ @objc func handleSingleTap(_ recognizer: UITapGestureRecognizer) {
expandHeader()
hideResults()
}
@@ -125,7 +125,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
func showResults(results: String) {
resultsLabel.text = results
disciplineLabel.text = ""
- resultsView.hidden = false
+ resultsView.isHidden = false
// 1. set animation to initial state
self.resultsViewLeft.constant = 0
@@ -136,35 +136,35 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
loader.alpha = 0
loader.startAnimating()
- loader.hidden = false
+ loader.isHidden = false
// 2. show indeterminate loader
- UIView.animateWithDuration(0.25, animations: { () -> Void in
+ UIView.animate(withDuration: 0.25, animations: { () -> Void in
self.loader.alpha = 1
}, completion: nil)
// 3. hide loader
- let animationDuration = NSTimeInterval(animMultiplier) * 0.15
- let options = UIViewAnimationOptions.CurveEaseInOut
- UIView.animateWithDuration(animationDuration, delay: 1.5,
+ let animationDuration = TimeInterval(animMultiplier) * 0.15
+ let options: UIViewAnimationOptions = []
+ UIView.animate(withDuration: animationDuration, delay: 1.5,
options: options, animations: {
self.loader.alpha = 0
}, completion: { finished in
// 4a. cleanup loader
self.loader.stopAnimating()
- self.loader.hidden = true
+ self.loader.isHidden = true
// 4b. zoom in the results view
- ViewAnimator.animateView(self.resultsView,
+ ViewAnimator.animateView(view: self.resultsView,
withDuration: 0.25,
andEasingFunction: LayoutConstraintEasing.EaseInOutMTF,
toTransform: CATransform3DIdentity)
// 4c. fade in the results view
- UIView.animateWithDuration(0.25, animations: { () -> Void in
+ UIView.animate(withDuration: 0.25, animations: { () -> Void in
self.resultsView.alpha = 1
- self.resultsView.transform = CGAffineTransformIdentity
+ self.resultsView.transform = CGAffineTransform.identity
}, completion: nil)
})
@@ -176,10 +176,10 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
*/
func hideResults() -> Void {
let animationDuration: Double = Double(animMultiplier * 0.3)
- let animationDelay: NSTimeInterval = 0
+ let animationDelay: TimeInterval = 0
- UIView.animateWithDuration(animationDuration, delay: animationDelay,
- options: nil, animations: { () -> Void in
+ UIView.animate(withDuration: animationDuration, delay: animationDelay,
+ options: [], animations: { () -> Void in
self.itemsView.alpha = 1.0
self.tableView.alpha = 1.0
}, completion: nil)
@@ -192,17 +192,17 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
searchIconTop, searchFieldHeight, searchTitleBottom
]
let toValues: [CGFloat] = [30, 40, 0]
- let animationDuration: NSTimeInterval = Double(animMultiplier * 0.2)
+ let animationDuration: TimeInterval = Double(animMultiplier * 0.2)
- LayoutConstraintAnimator(constraints: constraintsToAnimate, delay: 0,
+ _ = LayoutConstraintAnimator(constraints: constraintsToAnimate, delay: 0,
duration: animationDuration, toConstants: toValues,
easing: LayoutConstraintEasing.EaseInOut, completion: nil)
- UIView.animateWithDuration(Double(animMultiplier) * 0.2, animations: { () -> Void in
- self.searchTitleLabel.transform = CGAffineTransformMakeScale(0.75, 0.75)
+ UIView.animate(withDuration: Double(animMultiplier) * 0.2, animations: { () -> Void in
+ self.searchTitleLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
})
- UIView.animateWithDuration(Double(animMultiplier) * 0.3, animations: { () -> Void in
+ UIView.animate(withDuration: Double(animMultiplier) * 0.3, animations: { () -> Void in
self.tableView.alpha = 0.2
self.itemsView.alpha = 0.2
})
@@ -214,55 +214,55 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
]
let toValues: [CGFloat] = [70, 80, 18]
let animationDuration: Double = Double(animMultiplier * 0.3)
- let animationDelay: NSTimeInterval = 0
- LayoutConstraintAnimator(constraints: constraintsToAnimate,
+ _ = LayoutConstraintAnimator(constraints: constraintsToAnimate,
delay: 0, duration: animationDuration, toConstants: toValues,
easing: LayoutConstraintEasing.EaseInOut, completion: nil)
- UIView.animateWithDuration(Double(self.animMultiplier) * 0.3, animations: { () -> Void in
- self.searchTitleLabel.transform = CGAffineTransformIdentity
+ UIView.animate(withDuration: Double(self.animMultiplier) * 0.3, animations: { () -> Void in
+ self.searchTitleLabel.transform = CGAffineTransform.identity
})
- xButton.hidden = true
+ xButton.isHidden = true
let delay = Double(animMultiplier) * 0.1 * Double(NSEC_PER_SEC)
- let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
+ let time = DispatchTime.now() + delay
+ //let time = dispatch_time(dispatch_time_t(DISPATCH_TIME_NOW), Int64(delay))
- dispatch_after(time, dispatch_get_main_queue(), { () -> Void in
+ DispatchQueue.main.asyncAfter(deadline: time, execute: { () -> Void in
self.searchField.resignFirstResponder()
})
}
// MARK: - Appearance
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return UIStatusBarStyle.LightContent
+ override var preferredStatusBarStyle: UIStatusBarStyle {
+ return UIStatusBarStyle.lightContent
}
// MARK: - Text Field
- func textChanged() -> Void {
- self.xButton.hidden = count(self.searchField.text) == 0
+ @objc func textChanged() -> Void {
+ self.xButton.isHidden = self.searchField.text?.characters.count == 0
}
- func textFieldDidBeginEditing(textField: UITextField) {
+ func textFieldDidBeginEditing(_ textField: UITextField) {
self.collapseHeader()
- self.xButton.hidden = count(textField.text) == 0
+ self.xButton.isHidden = textField.text?.count == 0
}
- func textFieldShouldReturn(textField: UITextField) -> Bool {
- if count(textField.text) < 2 {
+ func textFieldShouldReturn(_ textField: UITextField) -> Bool {
+ guard let text = textField.text, text.count >= 2 else {
return false
}
- search(textField.text)
+ search(text: text)
return true
}
- func textFieldShouldClear(textField: UITextField) -> Bool {
+ func textFieldShouldClear(_ textField: UITextField) -> Bool {
return true
}
}
diff --git a/Animation/StyleKit/MotionStyleKit.swift b/Animation/StyleKit/MotionStyleKit.swift
index a78fa6a..3e80a61 100644
--- a/Animation/StyleKit/MotionStyleKit.swift
+++ b/Animation/StyleKit/MotionStyleKit.swift
@@ -15,7 +15,7 @@ public class MotionStyleKit : NSObject {
// MARK: - Cache
private struct Cache {
static var motion_Color: UIColor = UIColor(red: 0.000, green: 0.706, blue: 0.627, alpha: 1.000)
- static var motion_DarkColor: UIColor = MotionStyleKit.motion_Color.colorWithBrightness(0.525)
+ static var motion_DarkColor: UIColor = MotionStyleKit.motion_Color.colorWithBrightness(newBrightness: 0.525)
}
// MARK: - Colors
@@ -30,4 +30,4 @@ extension UIColor {
self.getHue(&hue, saturation: &saturation, brightness: nil, alpha: &alpha)
return UIColor(hue: hue, saturation: saturation, brightness: newBrightness, alpha: alpha)
}
-}
\ No newline at end of file
+}
diff --git a/Animation/TabBar/TabBarController.swift b/Animation/TabBar/TabBarController.swift
index f54b5cb..e4e08e5 100644
--- a/Animation/TabBar/TabBarController.swift
+++ b/Animation/TabBar/TabBarController.swift
@@ -34,10 +34,10 @@ class TabBarController: UITabBarController, UITabBarControllerDelegate {
super.viewDidLoad()
// set colors of UITabBar elements
- UITabBar.appearance().backgroundColor = UIColor.clearColor()
+ UITabBar.appearance().backgroundColor = UIColor.clear
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
- UITabBar.appearance().tintColor = UIColor.whiteColor()
+ UITabBar.appearance().tintColor = UIColor.white
// set tab bar height to custom height
var rect = tabBar.frame
@@ -46,99 +46,99 @@ 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)
-
- let indicatorContainerView = UIView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 60))
+ (self.tabBar.items![0]).image = UIImage(named: "dashboard_green")!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
+ (self.tabBar.items![0]).selectedImage = UIImage(named: "dashboard_white")!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
+ (self.tabBar.items![1]).image = UIImage(named: "stats_green")!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
+ (self.tabBar.items![1]).selectedImage = UIImage(named: "stats_white")!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
+ (self.tabBar.items![2]).image = UIImage(named: "contacts_green")!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
+ (self.tabBar.items![2]).selectedImage = UIImage(named: "contacts_white")!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
+
+ let indicatorContainerView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 60))
indicatorContainerView.backgroundColor = MotionStyleKit.motion_Color
- indicatorContainerView.setTranslatesAutoresizingMaskIntoConstraints(false)
+ indicatorContainerView.translatesAutoresizingMaskIntoConstraints = false
- view.sendSubviewToBack(indicatorContainerView)
+ view.sendSubview(toBack: indicatorContainerView)
view.addSubview(indicatorContainerView)
- let constraint1 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: 0.0)
+ let constraint1 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.bottom, multiplier: 1.0, constant: 0.0)
- let constraint2 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Left, multiplier: 1.0, constant: 0.0)
+ let constraint2 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.left, multiplier: 1.0, constant: 0.0)
- let constraint3 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Right, multiplier: 1.0, constant: 0.0)
+ let constraint3 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.right, multiplier: 1.0, constant: 0.0)
- let constraint4 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: tabBar, attribute: NSLayoutAttribute.Height, multiplier: 1.0, constant: 10.0)
+ let constraint4 = NSLayoutConstraint(item: indicatorContainerView, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: tabBar, attribute: NSLayoutAttribute.height, multiplier: 1.0, constant: 10.0)
view.addConstraints([constraint1, constraint2, constraint3, constraint4])
- indicatorView1 = UIView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width / 3, 60))
+ indicatorView1 = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width / 3, height: 60))
indicatorView1?.backgroundColor = MotionStyleKit.motion_DarkColor
- indicatorView2 = UIView(frame: CGRectMake(UIScreen.mainScreen().bounds.width / 3, 0, UIScreen.mainScreen().bounds.width / 3, 60))
+ indicatorView2 = UIView(frame: CGRect(x: UIScreen.main.bounds.width / 3, y: 0, width: UIScreen.main.bounds.width / 3, height: 60))
indicatorView2?.backgroundColor = MotionStyleKit.motion_DarkColor
indicatorView2?.layer.transform = CATransform3DMakeTranslation(0, 60, 0)
- indicatorView3 = UIView(frame: CGRectMake(2 * UIScreen.mainScreen().bounds.width / 3, 0, UIScreen.mainScreen().bounds.width / 3, 60))
+ indicatorView3 = UIView(frame: CGRect(x: 2 * UIScreen.main.bounds.width / 3, y: 0, width: UIScreen.main.bounds.width / 3, height: 60))
indicatorView3?.backgroundColor = MotionStyleKit.motion_DarkColor
indicatorView3?.layer.transform = CATransform3DMakeTranslation(0, 60, 0)
- previousItem = tabBar.items![0] as? UITabBarItem
+ previousItem = tabBar.items![0] as UITabBarItem
indicatorContainerView.addSubview(indicatorView1!)
indicatorContainerView.addSubview(indicatorView2!)
indicatorContainerView.addSubview(indicatorView3!)
- view.bringSubviewToFront(tabBar)
+ view.bringSubview(toFront: tabBar)
delegate = self
}
// MARK: - Tab Bar
- override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
+ override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
if item == previousItem {
return
}
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
+ if item == tabBar.items![0] as UITabBarItem || previousItem == tabBar.items![0] as UITabBarItem {
+ let translation: CGFloat = item == tabBar.items![0] as UITabBarItem ? 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))
+ ViewAnimator.animateView(view: iv1, withDuration: 0.4, andEasingFunction: LayoutConstraintEasing.EaseInMTF, toTransform: CATransform3DMakeTranslation(0.0, translation, 0.0))
}
}
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
+ 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
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))
+ ViewAnimator.animateView(view: iv2, withDuration: 0.4, andEasingFunction: LayoutConstraintEasing.EaseInMTF, toTransform: CATransform3DMakeTranslation(0.0, translation, 0.0))
}
}
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
+ 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
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))
+ ViewAnimator.animateView(view: iv3, withDuration: 0.4, andEasingFunction: LayoutConstraintEasing.EaseInMTF, toTransform: CATransform3DMakeTranslation(0.0, translation, 0.0))
}
}
previousItem = item
}
- func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
+ func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
var fromIndex = 0
var toIndex = 0
for index in 0...viewControllers!.count - 1 {
- if viewControllers![index] as! UIViewController == fromVC {
+ if viewControllers![index] as UIViewController == fromVC {
fromIndex = index
}
- if viewControllers![index] as! UIViewController == toVC {
+ if viewControllers![index] as UIViewController == toVC {
toIndex = index
}
}
diff --git a/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift b/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift
index 114194d..80e72ec 100644
--- a/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift
+++ b/Animation/TabBar/TabBarExampleAnimatedTransitioning.swift
@@ -21,25 +21,25 @@ class TabBarExampleAnimatedTransitioning: NSObject, UIViewControllerAnimatedTran
super.init()
}
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
- let to = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)! as UIViewController
- let from = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)! as UIViewController
+ let to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! as UIViewController
+ let from = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! as UIViewController
- let container = transitionContext.containerView()
- let duration = transitionDuration(transitionContext)
+ let container = transitionContext.containerView
+ _ = transitionDuration(using: transitionContext)
container.addSubview(to.view)
- var direction = toIndex > fromIndex ? CGFloat(-1) : CGFloat(1)
+ _ = toIndex > fromIndex ? CGFloat(-1) : CGFloat(1)
- if let toPeople = to as? TabBarPeopleViewController {
- to.view.transform = CGAffineTransformMakeTranslation(0, to.view.bounds.height)
- } else if let fromPeople = from as? TabBarPeopleViewController {
+ if to is TabBarPeopleViewController {
+ to.view.transform = CGAffineTransform(translationX: 0, y: to.view.bounds.height)
+ } else if from is TabBarPeopleViewController {
to.view.alpha = 1.0
container.addSubview(from.view)
} else {
@@ -47,20 +47,20 @@ class TabBarExampleAnimatedTransitioning: NSObject, UIViewControllerAnimatedTran
to.view.alpha = 0.0
}
- UIView.animateWithDuration(animMultiplier * transitionDuration(transitionContext), delay: animMultiplier * 0.0, options: nil, animations: { () -> Void in
+ UIView.animate(withDuration: animMultiplier * transitionDuration(using: transitionContext), delay: animMultiplier * 0.0, options: [], animations: { () -> Void in
to.view.alpha = 1.0
- to.view.transform = CGAffineTransformIdentity
+ to.view.transform = CGAffineTransform.identity
if let fromPeople = from as? TabBarPeopleViewController {
- fromPeople.view.transform = CGAffineTransformMakeTranslation(0, from.view.bounds.height)
+ fromPeople.view.transform = CGAffineTransform(translationX: 0, y: from.view.bounds.height)
}
}) { finished in
- to.view.transform = CGAffineTransformIdentity
- from.view.transform = CGAffineTransformIdentity
- transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
+ to.view.transform = CGAffineTransform.identity
+ from.view.transform = CGAffineTransform.identity
+ transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
diff --git a/Animation/TabBar/TabBarPeopleViewController.swift b/Animation/TabBar/TabBarPeopleViewController.swift
index 250f690..921dd16 100644
--- a/Animation/TabBar/TabBarPeopleViewController.swift
+++ b/Animation/TabBar/TabBarPeopleViewController.swift
@@ -14,9 +14,9 @@ class TabBarPeopleViewController: ExampleNobelViewController {
// MARK: - Table View
- override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- var cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath) as! TableViewCell
+ let cell = super.tableView(tableView, cellForRowAt: indexPath) as! TableViewCell
cell.smallLabel.text = ""
diff --git a/Animation/Table/TableView.swift b/Animation/Table/TableView.swift
index 35fc2ac..392fc2f 100644
--- a/Animation/Table/TableView.swift
+++ b/Animation/Table/TableView.swift
@@ -13,11 +13,11 @@ class TableView: UITableView {
}
override func awakeFromNib() {
- registerNib(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "TableViewCellID")
+ register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "TableViewCellID")
- registerNib(UINib(nibName: "TableViewHeaderCell", bundle: nil), forCellReuseIdentifier: "TableViewHeaderCellID")
+ register(UINib(nibName: "TableViewHeaderCell", bundle: nil), forCellReuseIdentifier: "TableViewHeaderCellID")
- self.separatorStyle = UITableViewCellSeparatorStyle.None
+ self.separatorStyle = UITableViewCellSeparatorStyle.none
}
}
diff --git a/Animation/Table/TableViewCell.swift b/Animation/Table/TableViewCell.swift
index da04792..1fd3c09 100644
--- a/Animation/Table/TableViewCell.swift
+++ b/Animation/Table/TableViewCell.swift
@@ -19,7 +19,7 @@ class TableViewCell: UITableViewCell {
label.textColor = MotionStyleKit.motion_Color
}
- override func setSelected(selected: Bool, animated: Bool) {
+ override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
diff --git a/Animation/Table/TableViewHeaderCell.swift b/Animation/Table/TableViewHeaderCell.swift
index 68b4f0f..77ca72f 100644
--- a/Animation/Table/TableViewHeaderCell.swift
+++ b/Animation/Table/TableViewHeaderCell.swift
@@ -17,7 +17,7 @@ class TableViewHeaderCell: UITableViewCell {
label.textColor = MotionStyleKit.motion_Color
}
- override func setSelected(selected: Bool, animated: Bool) {
+ override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
diff --git a/Animation/ViewAnimator.swift b/Animation/ViewAnimator.swift
index 35dbc64..20a58f4 100644
--- a/Animation/ViewAnimator.swift
+++ b/Animation/ViewAnimator.swift
@@ -18,9 +18,9 @@ class ViewAnimator: NSObject {
CATransaction.setAnimationTimingFunction(easingFunction)
let anim: CABasicAnimation = CABasicAnimation(keyPath: "transform")
- anim.fromValue = NSValue(CATransform3D: view.layer.transform)
- anim.toValue = NSValue(CATransform3D: transform)
- view.layer.addAnimation(anim, forKey: "animateTransform")
+ anim.fromValue = NSValue(caTransform3D: view.layer.transform)
+ anim.toValue = NSValue(caTransform3D: transform)
+ view.layer.add(anim, forKey: "animateTransform")
CATransaction.setCompletionBlock {
view.layer.transform = transform