diff --git a/CustomTransition Complete /CustomTransition.xcodeproj/project.pbxproj b/CustomTransition Complete /CustomTransition.xcodeproj/project.pbxproj
index 918d007..5cacee6 100644
--- a/CustomTransition Complete /CustomTransition.xcodeproj/project.pbxproj
+++ b/CustomTransition Complete /CustomTransition.xcodeproj/project.pbxproj
@@ -13,15 +13,15 @@
2B528D901BA8F076002F2C59 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2B528D8E1BA8F076002F2C59 /* LaunchScreen.xib */; };
2B528DAE1BA8F795002F2C59 /* TransitionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAD1BA8F795002F2C59 /* TransitionsTableViewController.swift */; };
2B528DB01BA8FAEF002F2C59 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAF1BA8FAEF002F2C59 /* DetailViewController.swift */; };
- 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB761BAB9C8A009D972F /* ZoomAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB751BAB9C8A009D972F /* ZoomAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB791BAB9FF2009D972F /* PopupAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB781BAB9FF2009D972F /* PopupAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB7B1BABA476009D972F /* CubeAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7A1BABA476009D972F /* CubeAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB7D1BAC8762009D972F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7C1BAC8762009D972F /* ImageViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB7F1BAC8A8D009D972F /* ImageAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7E1BAC8A8D009D972F /* ImageAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
+ 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; };
+ 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; };
+ 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; };
+ 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; };
+ 2BFDAB761BAB9C8A009D972F /* ZoomAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB751BAB9C8A009D972F /* ZoomAnimationController.swift */; };
+ 2BFDAB791BAB9FF2009D972F /* PopupAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB781BAB9FF2009D972F /* PopupAnimationController.swift */; };
+ 2BFDAB7B1BABA476009D972F /* CubeAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7A1BABA476009D972F /* CubeAnimationController.swift */; };
+ 2BFDAB7D1BAC8762009D972F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7C1BAC8762009D972F /* ImageViewController.swift */; };
+ 2BFDAB7F1BAC8A8D009D972F /* ImageAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7E1BAC8A8D009D972F /* ImageAnimationController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -154,11 +154,12 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
- LastUpgradeCheck = 0700;
+ LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Gian Nucci";
TargetAttributes = {
2B528D7F1BA8F076002F2C59 = {
CreatedOnToolsVersion = 6.4;
+ LastSwiftMigration = 0940;
};
};
};
@@ -243,13 +244,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -288,13 +299,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -313,6 +334,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -327,6 +349,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ciandt.digitalday.CustomTransitionComplete;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -340,6 +364,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ciandt.digitalday.CustomTransitionComplete;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/CustomTransition Complete /CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CustomTransition Complete /CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/CustomTransition Complete /CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/CustomTransition Complete /CustomTransition/AppDelegate.swift b/CustomTransition Complete /CustomTransition/AppDelegate.swift
index 532e175..6518e29 100644
--- a/CustomTransition Complete /CustomTransition/AppDelegate.swift
+++ b/CustomTransition Complete /CustomTransition/AppDelegate.swift
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
- func applicationWillResignActive(application: UIApplication) {
+ func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- func applicationDidEnterBackground(application: UIApplication) {
+ func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- func applicationWillEnterForeground(application: UIApplication) {
+ func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- func applicationDidBecomeActive(application: UIApplication) {
+ func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- func applicationWillTerminate(application: UIApplication) {
+ func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
diff --git a/CustomTransition Complete /CustomTransition/Base.lproj/Main.storyboard b/CustomTransition Complete /CustomTransition/Base.lproj/Main.storyboard
index a8e87b9..12cd931 100644
--- a/CustomTransition Complete /CustomTransition/Base.lproj/Main.storyboard
+++ b/CustomTransition Complete /CustomTransition/Base.lproj/Main.storyboard
@@ -1,7 +1,11 @@
-
-
+
+
+
+
+
-
+
+
@@ -25,9 +29,9 @@
-
+
-
+
@@ -126,19 +130,19 @@
-
+
-
+
@@ -160,19 +164,19 @@
-
+
-
+
@@ -194,7 +198,7 @@
-
+
@@ -222,13 +226,13 @@ How charged with punishments the scroll,
I am the master of my fate:
I am the captain of my soul.
-
+
-
+
-
+
@@ -258,19 +262,19 @@ I am the captain of my soul.
-
+
-
+
diff --git a/CustomTransition Complete /CustomTransition/CAAnimationBlocks.swift b/CustomTransition Complete /CustomTransition/CAAnimationBlocks.swift
index 0943d52..3a05b73 100755
--- a/CustomTransition Complete /CustomTransition/CAAnimationBlocks.swift
+++ b/CustomTransition Complete /CustomTransition/CAAnimationBlocks.swift
@@ -8,12 +8,12 @@
import UIKit
-extension CAAnimation {
+extension CAAnimation: CAAnimationDelegate {
- typealias StartBlock = ((Void) -> Void)
- typealias CompletionBlock = ((finished: Bool) -> Void)
+ typealias StartBlock = (() -> Void)
+ typealias CompletionBlock = ((_ finished: Bool) -> Void)
- private struct Blocks {
+ fileprivate struct Blocks {
static var startBlocks = Dictionary()
static var completionBlocks = Dictionary()
}
@@ -24,7 +24,7 @@ extension CAAnimation {
}
set {
Blocks.startBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
@@ -34,25 +34,25 @@ extension CAAnimation {
}
set {
Blocks.completionBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
- public override func animationDidStart(anim: CAAnimation)
+ public func animationDidStart(_ anim: CAAnimation)
{
if let block = self.startBlock {
block()
- Blocks.startBlocks.removeValueForKey(self)
+ Blocks.startBlocks.removeValue(forKey: self)
}
}
- public override func animationDidStop(anim: CAAnimation, finished flag: Bool)
+ public func animationDidStop(_ anim: CAAnimation, finished flag: Bool)
{
if let block = self.completionBlock {
- block(finished: flag)
- Blocks.completionBlocks.removeValueForKey(self)
+ block(flag)
+ Blocks.completionBlocks.removeValue(forKey: self)
}
}
-}
\ No newline at end of file
+}
diff --git a/CustomTransition Complete /CustomTransition/Transitions/CubeAnimationController.swift b/CustomTransition Complete /CustomTransition/Transitions/CubeAnimationController.swift
index 3cb71f1..2948474 100644
--- a/CustomTransition Complete /CustomTransition/Transitions/CubeAnimationController.swift
+++ b/CustomTransition Complete /CustomTransition/Transitions/CubeAnimationController.swift
@@ -10,7 +10,7 @@ import UIKit
class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewControllerAnimatedTransitioning, UIGestureRecognizerDelegate {
// constants
- let Rotation = CGFloat(M_PI_2)
+ let Rotation = CGFloat(Double.pi/2)
let Projection: CGFloat = 1 / -600
let Duration: CFTimeInterval = 0.65
@@ -21,25 +21,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// interactive transition properties
var interactive = false
var startTouchPoint: CGPoint?
- var animationTimer: NSTimer?
+ var animationTimer: Timer?
//MARK: - UIViewControllerAnimatedTransitioning
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return Duration
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
self.transitionContext = transitionContext
- let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let (containerView, sourceView, destinationView) = self.transitionContextViews(transitionContext)
// since the detail view was just built, it needs to be added to the view heirarchy
containerView.addSubview(destinationView)
- destinationView.frame = transitionContext.finalFrameForViewController(toViewController)
+ destinationView.frame = transitionContext.finalFrame(for: toViewController)
// setup the 3D scene by setting perspective in the container and configurin the view positions
self.setupScene(containerView, sourceView: sourceView, destinationView: destinationView)
@@ -60,15 +60,15 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
destinationViewAnimation.completionBlock = { (success: Bool) -> Void in
// whenever this animation completes we need to update the context and determine
// if the transition successfully completed.
- transitionContext.completeTransition(success && !transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(success && !transitionContext.transitionWasCancelled)
}
- sourceView.layer.addAnimation(sourceViewAnimation, forKey: sourceViewAnimation.keyPath)
- destinationView.layer.addAnimation(destinationViewAnimation, forKey: destinationViewAnimation.keyPath)
+ sourceView.layer.add(sourceViewAnimation, forKey: sourceViewAnimation.keyPath)
+ destinationView.layer.add(destinationViewAnimation, forKey: destinationViewAnimation.keyPath)
}
- func animationEnded(transitionCompleted: Bool)
+ func animationEnded(_ transitionCompleted: Bool)
{
self.transitionContext = nil
self.interactive = false
@@ -78,29 +78,29 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - UIViewControllerInteractiveTransitioning
- override func startInteractiveTransition(transitionContext: UIViewControllerContextTransitioning)
+ override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning)
{
super.startInteractiveTransition(transitionContext)
// the gesture has already began once this method fires, so we cannot rely on the Begin state for the
// gesture to record the first touch point. instead, capture it here when the interactive transition begins.
- self.startTouchPoint = self.interactivePopGestureRecognizer?.locationInView(transitionContext.containerView())
+ self.startTouchPoint = self.interactivePopGestureRecognizer?.location(in: transitionContext.containerView)
}
- override func cancelInteractiveTransition() {
- super.cancelInteractiveTransition()
+ override func cancel() {
+ super.cancel()
// here we need to reset the layer properties for our views to their original values.
// by doing this, we fix an animation flicker that shows the views in their final state
let transitionContext = self.transitionContext!
let (_, sourceView, destinationView) = self.transitionContextViews(transitionContext)
- let sourceViewAnimation = sourceView.layer.animationForKey("transform") as! CABasicAnimation
- let destinationViewAnimation = destinationView.layer.animationForKey("transform") as! CABasicAnimation
+ let sourceViewAnimation = sourceView.layer.animation(forKey: "transform") as! CABasicAnimation
+ let destinationViewAnimation = destinationView.layer.animation(forKey: "transform") as! CABasicAnimation
- sourceView.layer.transform = (sourceViewAnimation.fromValue as! NSValue).CATransform3DValue
- destinationView.layer.transform = (destinationViewAnimation.fromValue as! NSValue).CATransform3DValue
+ sourceView.layer.transform = (sourceViewAnimation.fromValue as! NSValue).caTransform3DValue
+ destinationView.layer.transform = (destinationViewAnimation.fromValue as! NSValue).caTransform3DValue
}
@@ -111,12 +111,12 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
var interactivePopGestureRecognizer: UIGestureRecognizer? {
didSet {
self.interactivePopGestureRecognizer?.delegate = self
- self.interactivePopGestureRecognizer?.addTarget(self, action: "screenEdgeDidPan:")
+ self.interactivePopGestureRecognizer?.addTarget(self, action: #selector(CubeAnimationController.screenEdgeDidPan(_:)))
}
}
- func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool
+ func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
{
// prevent the gesture from starting when we're in the middle of animating
// to a new target value.
@@ -133,25 +133,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
}
- func screenEdgeDidPan(gesture: UIGestureRecognizer)
+ @objc func screenEdgeDidPan(_ gesture: UIGestureRecognizer)
{
if let transitionContext = self.transitionContext {
- let containerView = transitionContext.containerView()
- let touchPoint = gesture.locationInView(containerView)
- let progress = touchPoint.x / CGRectGetWidth(containerView!.frame)
+ let containerView = transitionContext.containerView
+ let touchPoint = gesture.location(in: containerView)
+ let progress = touchPoint.x / containerView.frame.width
switch (gesture.state) {
- case .Changed:
- self.updateInteractiveTransition(progress)
+ case .changed:
+ self.update(progress)
if progress >= 0.995 {
- self.finishInteractiveTransition()
+ self.finish()
}
break
- case .Ended, .Cancelled:
+ case .ended, .cancelled:
// when a gesture ends, we need to determine how far through the user
// was through the animation, and then advance our animation to either a
@@ -174,10 +174,10 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - Animation Timer
- func animateToPercentComplete(percent: CGFloat)
+ func animateToPercentComplete(_ percent: CGFloat)
{
if self.animationTimer == nil {
- self.animationTimer = NSTimer.scheduledTimerWithTimeInterval(1/60, target: self, selector: "adjustPercentComplete:", userInfo: Float(percent), repeats: true)
+ self.animationTimer = Timer.scheduledTimer(timeInterval: 1/60, target: self, selector: #selector(CubeAnimationController.adjustPercentComplete(_:)), userInfo: Float(percent), repeats: true)
}
}
@@ -189,22 +189,22 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
}
- func adjustPercentComplete(timer: NSTimer)
+ @objc func adjustPercentComplete(_ timer: Timer)
{
let targetPercent = timer.userInfo as! CGFloat
let delta = (targetPercent - self.percentComplete) * 0.1
- self.updateInteractiveTransition(self.percentComplete + delta)
+ self.update(self.percentComplete + delta)
if abs(delta) < 0.0001 {
self.stopAnimationTimer()
if targetPercent == 1 {
- self.finishInteractiveTransition()
+ self.finish()
}
else {
- self.cancelInteractiveTransition()
+ self.cancel()
}
}
}
@@ -213,14 +213,14 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - Helpers
// helper method to retrieve the contents of the transition context
- func transitionContextViews(transitionContext: UIViewControllerContextTransitioning) -> (containerView: UIView, sourceView: UIView, destinationView: UIView)
+ func transitionContextViews(_ transitionContext: UIViewControllerContextTransitioning) -> (containerView: UIView, sourceView: UIView, destinationView: UIView)
{
- let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
- let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- return (transitionContext.containerView()!, fromViewController.view, toViewController.view)
+ let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
+ let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ return (transitionContext.containerView, fromViewController.view, toViewController.view)
}
- func setupScene(containerView: UIView, sourceView: UIView, destinationView: UIView)
+ func setupScene(_ containerView: UIView, sourceView: UIView, destinationView: UIView)
{
// setup the 3D scene by setting perspective in the container and configuring the view positions
// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW13
@@ -230,25 +230,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// calculate the z-distance as a ratio of the width of the container.
// this keeps the edges of the cube sides aligned when rotating with different screen sizes
- let z = -(0.5 * CGRectGetWidth(self.transitionContext!.containerView()!.frame))
+ let z = -(0.5 * self.transitionContext!.containerView.frame.width)
sourceView.layer.zPosition = z
sourceView.layer.anchorPointZ = z
destinationView.layer.zPosition = z
destinationView.layer.anchorPointZ = z
}
- func createCubeTransformAnimation(rotation: CGFloat, view: UIView, presenting: Bool) -> CABasicAnimation
+ func createCubeTransformAnimation(_ rotation: CGFloat, view: UIView, presenting: Bool) -> CABasicAnimation
{
let viewFromTransform = CATransform3DMakeRotation(rotation, 0, 1, 0)
let transformAnimation = CABasicAnimation(keyPath: "transform")
if presenting {
- transformAnimation.fromValue = NSValue(CATransform3D: viewFromTransform)
- transformAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity)
+ transformAnimation.fromValue = NSValue(caTransform3D: viewFromTransform)
+ transformAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
}
else {
- transformAnimation.fromValue = NSValue(CATransform3D: CATransform3DIdentity)
- transformAnimation.toValue = NSValue(CATransform3D: viewFromTransform)
+ transformAnimation.fromValue = NSValue(caTransform3D: CATransform3DIdentity)
+ transformAnimation.toValue = NSValue(caTransform3D: viewFromTransform)
}
transformAnimation.duration = Duration
@@ -258,7 +258,7 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// set the view's layer to the final value. fixes flickering at the end of the animation
- view.layer.transform = (transformAnimation.toValue as! NSValue).CATransform3DValue
+ view.layer.transform = (transformAnimation.toValue as! NSValue).caTransform3DValue
return transformAnimation
}
diff --git a/CustomTransition Complete /CustomTransition/Transitions/ImageAnimationController.swift b/CustomTransition Complete /CustomTransition/Transitions/ImageAnimationController.swift
index 17463b8..b119947 100644
--- a/CustomTransition Complete /CustomTransition/Transitions/ImageAnimationController.swift
+++ b/CustomTransition Complete /CustomTransition/Transitions/ImageAnimationController.swift
@@ -12,8 +12,8 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
var reverseAnimation = false
lazy var animationImageView: UIImageView = {
- let imageView = UIImageView(frame: CGRectZero)
- imageView.contentMode = .ScaleAspectFill
+ let imageView = UIImageView(frame: CGRect.zero)
+ imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.translatesAutoresizingMaskIntoConstraints = true
return imageView
@@ -22,7 +22,7 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
//MARK: -
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
if self.reverseAnimation {
return 0.4
@@ -31,7 +31,7 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -41,47 +41,47 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
}
- func animateIn(transitionContext: UIViewControllerContextTransitioning) {
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning) {
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
// pull out values we need from the context
- let tableNavigationController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as! UINavigationController
+ let tableNavigationController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as! UINavigationController
let tableViewController = tableNavigationController.topViewController as! TransitionsTableViewController
- let imageViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as! ImageViewController
- let containerView = transitionContext.containerView()
- let destinationViewFrame = transitionContext.finalFrameForViewController(imageViewController)
+ let imageViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as! ImageViewController
+ let containerView = transitionContext.containerView
+ let destinationViewFrame = transitionContext.finalFrame(for: imageViewController)
// size the destination view
imageViewController.view.frame = destinationViewFrame
- containerView!.addSubview(imageViewController.view)
- containerView!.layoutIfNeeded()
+ containerView.addSubview(imageViewController.view)
+ containerView.layoutIfNeeded()
// hide the destination view until the image animates into place
- imageViewController.view.hidden = true
+ imageViewController.view.isHidden = true
// get a reference to the cell's image view
- let indexPath = NSIndexPath(forRow: 3, inSection: 0)
- let imageCell = tableViewController.tableView.cellForRowAtIndexPath(indexPath)!
+ let indexPath = IndexPath(row: 3, section: 0)
+ let imageCell = tableViewController.tableView.cellForRow(at: indexPath)!
let cellImageView = imageCell.contentView.subviews.last as! UIImageView
// configure the animation image view with the cell's image and frame
self.animationImageView.image = cellImageView.image
- self.animationImageView.frame = cellImageView.convertRect(cellImageView.bounds, toView: containerView)
- containerView!.addSubview(self.animationImageView)
+ self.animationImageView.frame = cellImageView.convert(cellImageView.bounds, to: containerView)
+ containerView.addSubview(self.animationImageView)
// fade in the animation image
self.animationImageView.alpha = 0
- UIView.animateWithDuration(duration * 0.25, delay: 0, options: .CurveEaseOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration * 0.25, delay: 0, options: .curveEaseOut, animations: { () -> Void in
self.animationImageView.alpha = 1
}, completion: nil)
// size the image to match the destination view frame
- let destinationImageFrame = imageViewController.imageView.convertRect(imageViewController.imageView.bounds, toView: containerView)
+ let destinationImageFrame = imageViewController.imageView.convert(imageViewController.imageView.bounds, to: containerView)
- UIView.animateWithDuration(duration * 0.75, delay: duration * 0.25, options: .CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration * 0.75, delay: duration * 0.25, options: UIViewAnimationOptions(), animations: { () -> Void in
// resize the image to match the size of the destination view
self.animationImageView.frame = destinationImageFrame
@@ -92,49 +92,49 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
self.animationImageView.removeFromSuperview()
// show the destination view
- imageViewController.view.hidden = false
+ imageViewController.view.isHidden = false
// finish the transition
transitionContext.completeTransition(true)
})
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning) {
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning) {
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
// pull out values we need from the context
- let tableNavigationController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as! UINavigationController
+ let tableNavigationController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as! UINavigationController
let tableViewController = tableNavigationController.topViewController as! TransitionsTableViewController
- let imageViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as! ImageViewController
- let containerView = transitionContext.containerView()
+ let imageViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as! ImageViewController
+ let containerView = transitionContext.containerView
// get a reference to the cell's image view
- let indexPath = NSIndexPath(forRow: 3, inSection: 0)
- let imageCell = tableViewController.tableView.cellForRowAtIndexPath(indexPath)!
+ let indexPath = IndexPath(row: 3, section: 0)
+ let imageCell = tableViewController.tableView.cellForRow(at: indexPath)!
let cellImageView = imageCell.contentView.subviews.last as! UIImageView
// configure the animation image view with the cell's image and frame
self.animationImageView.image = cellImageView.image
- self.animationImageView.frame = imageViewController.imageView.convertRect(imageViewController.imageView.bounds, toView: containerView)
+ self.animationImageView.frame = imageViewController.imageView.convert(imageViewController.imageView.bounds, to: containerView)
// remove the view we're transitioning from
imageViewController.view.removeFromSuperview()
// place the animation image on top
- containerView!.addSubview(self.animationImageView)
+ containerView.addSubview(self.animationImageView)
// resize the animation image to match the cell image view's frame
- let destinationImageFrame = cellImageView.convertRect(cellImageView.bounds, toView: containerView)
+ let destinationImageFrame = cellImageView.convert(cellImageView.bounds, to: containerView)
- UIView.animateWithDuration(duration * 0.75, delay: 0, options: .CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration * 0.75, delay: 0, options: UIViewAnimationOptions(), animations: { () -> Void in
self.animationImageView.frame = destinationImageFrame
}, completion: nil)
// fade out the animation image and end the transition
- UIView.animateWithDuration(duration * 0.25, delay: duration * 0.75, options: .CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration * 0.25, delay: duration * 0.75, options: UIViewAnimationOptions(), animations: { () -> Void in
self.animationImageView.alpha = 0
diff --git a/CustomTransition Complete /CustomTransition/Transitions/PopupAnimationController.swift b/CustomTransition Complete /CustomTransition/Transitions/PopupAnimationController.swift
index 90b545b..ef93462 100644
--- a/CustomTransition Complete /CustomTransition/Transitions/PopupAnimationController.swift
+++ b/CustomTransition Complete /CustomTransition/Transitions/PopupAnimationController.swift
@@ -12,19 +12,19 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
var reverseAnimation: Bool = false
lazy var dimmerView: UIView = {
- let view = UIView(frame: CGRectZero)
- view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.8)
+ let view = UIView(frame: CGRect.zero)
+ view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
return view
}()
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 1.25
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -34,19 +34,19 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
}
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let duration = self.transitionDuration(transitionContext)
- let containerView = transitionContext.containerView()
- let popupViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let duration = self.transitionDuration(using: transitionContext)
+ let containerView = transitionContext.containerView
+ let popupViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let popupView = popupViewController.view
let popupSize = popupViewController.preferredContentSize
let scaleValues: [NSValue] = [
- NSValue(CATransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, -500, 0), 0, 0, 1)),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.75, 1), 0, 200, 0)),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(0.8, 1.3, 1), 0, -55, 0)),
- NSValue(CATransform3D: CATransform3DIdentity)
+ NSValue(caTransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, -500, 0), 0, 0, 1)),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.75, 1), 0, 200, 0)),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(0.8, 1.3, 1), 0, -55, 0)),
+ NSValue(caTransform3D: CATransform3DIdentity)
]
let transformAnimation = CAKeyframeAnimation(keyPath: "transform")
@@ -72,36 +72,36 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
dimmerFadeAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
dimmerFadeAnimation.completionBlock = { (finished: Bool) -> Void in
if finished {
- containerView!.addSubview(popupView)
+ containerView.addSubview(popupView!)
// set the layer to its final value before adding the animation
- popupView.layer.transform = CATransform3DIdentity
+ popupView?.layer.transform = CATransform3DIdentity
- popupView.layer.addAnimation(transformAnimation, forKey: "transformAnimation")
+ popupView?.layer.add(transformAnimation, forKey: "transformAnimation")
}
else {
transitionContext.completeTransition(finished)
}
}
- popupView.frame = CGRect(origin: CGPointZero, size: popupSize)
- popupView.center = containerView!.center
+ popupView?.frame = CGRect(origin: CGPoint.zero, size: popupSize)
+ popupView?.center = containerView.center
// display the dimmer
- containerView!.addSubview(self.dimmerView)
- self.dimmerView.frame = containerView!.bounds
+ containerView.addSubview(self.dimmerView)
+ self.dimmerView.frame = containerView.bounds
// set the layer to its final value before adding the animation
self.dimmerView.layer.opacity = 1
- self.dimmerView.layer.addAnimation(dimmerFadeAnimation, forKey: "dimmerFadeAnimation")
+ self.dimmerView.layer.add(dimmerFadeAnimation, forKey: "dimmerFadeAnimation")
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let duration = self.transitionDuration(transitionContext)
- let popupViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let duration = self.transitionDuration(using: transitionContext)
+ let popupViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let popupView = popupViewController.view
let dimmerFadeAnimation = CABasicAnimation(keyPath: "opacity")
@@ -115,9 +115,9 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
let scaleValues: [NSValue] = [
- NSValue(CATransform3D: CATransform3DIdentity),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.9, 1), 0, -100, 0)),
- NSValue(CATransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, 500, 0), 0, 0.5, 1)),
+ NSValue(caTransform3D: CATransform3DIdentity),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.9, 1), 0, -100, 0)),
+ NSValue(caTransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, 500, 0), 0, 0.5, 1)),
]
let transformAnimation = CAKeyframeAnimation(keyPath: "transform")
@@ -132,7 +132,7 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
transformAnimation.completionBlock = { (finished: Bool) -> Void in
if finished {
self.dimmerView.layer.opacity = 0
- self.dimmerView.layer.addAnimation(dimmerFadeAnimation, forKey: "fadeAnimation")
+ self.dimmerView.layer.add(dimmerFadeAnimation, forKey: "fadeAnimation")
}
else {
transitionContext.completeTransition(finished)
@@ -141,8 +141,8 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
// its important to set the layer to its final values when adding the animation, without this,
// you can get a flicker showing the original values when the animation ends.
- popupView.layer.transform = scaleValues.last!.CATransform3DValue
- popupView.layer.addAnimation(transformAnimation, forKey: "transformAnimation")
+ popupView?.layer.transform = scaleValues.last!.caTransform3DValue
+ popupView?.layer.add(transformAnimation, forKey: "transformAnimation")
}
}
diff --git a/CustomTransition Complete /CustomTransition/Transitions/ZoomAnimationController.swift b/CustomTransition Complete /CustomTransition/Transitions/ZoomAnimationController.swift
index e8f419c..68f3dbb 100644
--- a/CustomTransition Complete /CustomTransition/Transitions/ZoomAnimationController.swift
+++ b/CustomTransition Complete /CustomTransition/Transitions/ZoomAnimationController.swift
@@ -9,7 +9,7 @@
import UIKit
class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
- private struct Zoom
+ fileprivate struct Zoom
{
static let minimum: CGFloat = 0.1, maximum: CGFloat = 5.0
}
@@ -19,13 +19,13 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
//MARK: -
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 0.4
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -37,34 +37,34 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
//MARK: - Animations
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
- let detailViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
+ let detailViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let detailView = detailViewController.view
let tableView = tableViewController.view
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
// since the detail view was just built, it needs to be added to the view heirarchy
- containerView.addSubview(detailView)
- detailView.frame = containerView.bounds
+ containerView.addSubview(detailView!)
+ detailView?.frame = containerView.bounds
- detailView.alpha = 0
- detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
+ detailView?.alpha = 0
+ detailView?.transform = CGAffineTransform(scaleX: Zoom.maximum, y: Zoom.maximum)
- UIView.animateWithDuration(duration, delay:0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration, delay:0, options: UIViewAnimationOptions(), animations: { () -> Void in
- detailView.alpha = 1
- detailView.transform = CGAffineTransformIdentity
- tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
+ detailView?.alpha = 1
+ detailView?.transform = CGAffineTransform.identity
+ tableView?.transform = CGAffineTransform(scaleX: Zoom.minimum, y: Zoom.minimum)
}) { (animationCompleted: Bool) -> Void in
// return the table view back to its original state
- tableView.transform = CGAffineTransformIdentity
+ tableView?.transform = CGAffineTransform.identity
// when the animation is done we need to complete the transition
transitionContext.completeTransition(animationCompleted)
@@ -72,30 +72,30 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- let detailViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ let detailViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let detailView = detailViewController.view
let tableView = tableViewController.view
- tableView.frame = transitionContext.finalFrameForViewController(tableViewController)
- tableView.alpha = 0
- tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
+ tableView?.frame = transitionContext.finalFrame(for: tableViewController)
+ tableView?.alpha = 0
+ tableView?.transform = CGAffineTransform(scaleX: Zoom.minimum, y: Zoom.minimum)
- UIView.animateWithDuration(self.transitionDuration(transitionContext), delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
+ UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in
- tableView.alpha = 1
- tableView.transform = CGAffineTransformIdentity
+ tableView?.alpha = 1
+ tableView?.transform = CGAffineTransform.identity
- detailView.alpha = 0
- detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
+ detailView?.alpha = 0
+ detailView?.transform = CGAffineTransform(scaleX: Zoom.maximum, y: Zoom.maximum)
}) { (animationCompleted: Bool) -> Void in
- detailView.alpha = 1
- detailView.transform = CGAffineTransformIdentity
+ detailView?.alpha = 1
+ detailView?.transform = CGAffineTransform.identity
transitionContext.completeTransition(animationCompleted)
}
diff --git a/CustomTransition Complete /CustomTransition/View Controllers/DetailViewController.swift b/CustomTransition Complete /CustomTransition/View Controllers/DetailViewController.swift
index 7d2787a..8d72fba 100644
--- a/CustomTransition Complete /CustomTransition/View Controllers/DetailViewController.swift
+++ b/CustomTransition Complete /CustomTransition/View Controllers/DetailViewController.swift
@@ -15,14 +15,14 @@ class DetailViewController: UIViewController {
override func viewDidLoad()
{
super.viewDidLoad()
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(DetailViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
}
diff --git a/CustomTransition Complete /CustomTransition/View Controllers/ImageViewController.swift b/CustomTransition Complete /CustomTransition/View Controllers/ImageViewController.swift
index ed1029e..f30466a 100644
--- a/CustomTransition Complete /CustomTransition/View Controllers/ImageViewController.swift
+++ b/CustomTransition Complete /CustomTransition/View Controllers/ImageViewController.swift
@@ -13,31 +13,31 @@ class ImageViewController: UIViewController {
@IBOutlet weak var quoteLabel: UILabel!
- override func viewWillAppear(animated: Bool) {
+ override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.quoteLabel.alpha = 0
}
- override func viewDidAppear(animated: Bool) {
+ override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
- UIView.animateWithDuration(0.3, animations: { () -> Void in
+ UIView.animate(withDuration: 0.3, animations: { () -> Void in
self.quoteLabel.alpha = 1
})
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
- override func touchesEnded(touches: Set, withEvent event: UIEvent?) {
+ override func touchesEnded(_ touches: Set, with event: UIEvent?) {
- UIView.animateWithDuration(0.15, animations: { () -> Void in
+ UIView.animate(withDuration: 0.15, animations: { () -> Void in
self.quoteLabel.alpha = 0
- }) { (finished: Bool) -> Void in
- self.dismissViewControllerAnimated(true, completion: nil)
- }
+ }, completion: { (finished: Bool) -> Void in
+ self.dismiss(animated: true, completion: nil)
+ })
}
}
diff --git a/CustomTransition Complete /CustomTransition/View Controllers/PopupViewController.swift b/CustomTransition Complete /CustomTransition/View Controllers/PopupViewController.swift
index bb2377f..32ddd2c 100644
--- a/CustomTransition Complete /CustomTransition/View Controllers/PopupViewController.swift
+++ b/CustomTransition Complete /CustomTransition/View Controllers/PopupViewController.swift
@@ -17,25 +17,25 @@ class PopupViewController: UIViewController, UIViewControllerTransitioningDelega
self.preferredContentSize = CGSize(width: 200, height: 100)
self.view.clipsToBounds = true
self.view.layer.cornerRadius = 4
- self.view.layer.borderColor = UIColor.darkGrayColor().CGColor
+ self.view.layer.borderColor = UIColor.darkGray.cgColor
self.view.layer.borderWidth = 1
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(PopupViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
required init?(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
self.transitioningDelegate = self
- self.modalPresentationStyle = .Custom
+ self.modalPresentationStyle = .custom
}
@@ -43,13 +43,13 @@ class PopupViewController: UIViewController, UIViewControllerTransitioningDelega
lazy var popupAnimation = PopupAnimationController()
- func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.popupAnimation.reverseAnimation = false
return self.popupAnimation
}
- func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.popupAnimation.reverseAnimation = true
return self.popupAnimation
diff --git a/CustomTransition Complete /CustomTransition/View Controllers/TransitionsTableViewController.swift b/CustomTransition Complete /CustomTransition/View Controllers/TransitionsTableViewController.swift
index a2ee062..bb177ed 100644
--- a/CustomTransition Complete /CustomTransition/View Controllers/TransitionsTableViewController.swift
+++ b/CustomTransition Complete /CustomTransition/View Controllers/TransitionsTableViewController.swift
@@ -10,34 +10,34 @@ import UIKit
class TransitionsTableViewController: UITableViewController, UIViewControllerTransitioningDelegate, UINavigationControllerDelegate {
- override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch (indexPath.row) {
case 0:
- let zoomVC = self.storyboard!.instantiateViewControllerWithIdentifier("detailViewController")
+ let zoomVC = self.storyboard!.instantiateViewController(withIdentifier: "detailViewController")
zoomVC.transitioningDelegate = self
- zoomVC.modalPresentationStyle = .Custom
- self.presentViewController(zoomVC, animated: true, completion: nil)
+ zoomVC.modalPresentationStyle = .custom
+ self.present(zoomVC, animated: true, completion: nil)
break
case 1:
- let popupVC = self.storyboard!.instantiateViewControllerWithIdentifier("popupViewController")
- self.presentViewController(popupVC, animated: true, completion: nil)
+ let popupVC = self.storyboard!.instantiateViewController(withIdentifier: "popupViewController")
+ self.present(popupVC, animated: true, completion: nil)
break
case 2:
- let cubeVC = self.storyboard!.instantiateViewControllerWithIdentifier("cubeViewController")
+ let cubeVC = self.storyboard!.instantiateViewController(withIdentifier: "cubeViewController")
self.navigationController?.delegate = self
self.navigationController?.pushViewController(cubeVC, animated: true)
break
case 3:
- let imageVC = self.storyboard!.instantiateViewControllerWithIdentifier("imageViewController")
+ let imageVC = self.storyboard!.instantiateViewController(withIdentifier: "imageViewController")
imageVC.transitioningDelegate = self
- imageVC.modalPresentationStyle = .Custom
- self.presentViewController(imageVC, animated: true, completion: nil)
+ imageVC.modalPresentationStyle = .custom
+ self.present(imageVC, animated: true, completion: nil)
break
default:
break
}
- tableView.deselectRowAtIndexPath(indexPath, animated: false);
+ tableView.deselectRow(at: indexPath, animated: false);
}
//MARK: -
@@ -46,28 +46,28 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
lazy var cubeAnimation = CubeAnimationController()
lazy var imageAnimation = ImageAnimationController()
- func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
- if presented.isKindOfClass(DetailViewController) {
+ if presented.isKind(of: DetailViewController.self) {
self.zoomAnimation.reverseAnimation = false
return self.zoomAnimation
}
- else if presented.isKindOfClass(ImageViewController) {
+ else if presented.isKind(of: ImageViewController.self) {
self.imageAnimation.reverseAnimation = false
return self.imageAnimation
}
return nil
}
- func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
- if dismissed.isKindOfClass(DetailViewController) {
+ if dismissed.isKind(of: DetailViewController.self) {
self.zoomAnimation.reverseAnimation = true
return self.zoomAnimation
}
- else if dismissed.isKindOfClass(ImageViewController) {
+ else if dismissed.isKind(of: ImageViewController.self) {
self.imageAnimation.reverseAnimation = true
return self.imageAnimation
}
@@ -76,11 +76,11 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
//MARK: - UINavigationControllerDelegate
- func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
switch (operation) {
- case .Pop:
+ case .pop:
self.cubeAnimation.reverseAnimation = true
break
@@ -95,7 +95,7 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
return self.cubeAnimation
}
- func navigationController(navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
+ func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
{
if self.cubeAnimation.interactive {
return self.cubeAnimation
diff --git a/CustomTransition Demo/CustomTransition.xcodeproj/project.pbxproj b/CustomTransition Demo/CustomTransition.xcodeproj/project.pbxproj
index c5adc7d..171ce81 100644
--- a/CustomTransition Demo/CustomTransition.xcodeproj/project.pbxproj
+++ b/CustomTransition Demo/CustomTransition.xcodeproj/project.pbxproj
@@ -13,10 +13,10 @@
2B528D901BA8F076002F2C59 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2B528D8E1BA8F076002F2C59 /* LaunchScreen.xib */; };
2B528DAE1BA8F795002F2C59 /* TransitionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAD1BA8F795002F2C59 /* TransitionsTableViewController.swift */; };
2B528DB01BA8FAEF002F2C59 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAF1BA8FAEF002F2C59 /* DetailViewController.swift */; };
- 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; settings = {ASSET_TAGS = (); }; };
+ 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; };
+ 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; };
+ 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; };
+ 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -139,11 +139,12 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
- LastUpgradeCheck = 0700;
+ LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Gian Nucci";
TargetAttributes = {
2B528D7F1BA8F076002F2C59 = {
CreatedOnToolsVersion = 6.4;
+ LastSwiftMigration = 0940;
};
};
};
@@ -223,13 +224,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -268,13 +279,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -293,6 +314,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -307,6 +329,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.ciandt.digitalday.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -320,6 +344,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.ciandt.digitalday.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/CustomTransition Demo/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CustomTransition Demo/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/CustomTransition Demo/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/CustomTransition Demo/CustomTransition/AppDelegate.swift b/CustomTransition Demo/CustomTransition/AppDelegate.swift
index 532e175..6518e29 100644
--- a/CustomTransition Demo/CustomTransition/AppDelegate.swift
+++ b/CustomTransition Demo/CustomTransition/AppDelegate.swift
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
- func applicationWillResignActive(application: UIApplication) {
+ func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- func applicationDidEnterBackground(application: UIApplication) {
+ func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- func applicationWillEnterForeground(application: UIApplication) {
+ func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- func applicationDidBecomeActive(application: UIApplication) {
+ func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- func applicationWillTerminate(application: UIApplication) {
+ func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
diff --git a/CustomTransition Demo/CustomTransition/CAAnimationBlocks.swift b/CustomTransition Demo/CustomTransition/CAAnimationBlocks.swift
index 0943d52..3a05b73 100755
--- a/CustomTransition Demo/CustomTransition/CAAnimationBlocks.swift
+++ b/CustomTransition Demo/CustomTransition/CAAnimationBlocks.swift
@@ -8,12 +8,12 @@
import UIKit
-extension CAAnimation {
+extension CAAnimation: CAAnimationDelegate {
- typealias StartBlock = ((Void) -> Void)
- typealias CompletionBlock = ((finished: Bool) -> Void)
+ typealias StartBlock = (() -> Void)
+ typealias CompletionBlock = ((_ finished: Bool) -> Void)
- private struct Blocks {
+ fileprivate struct Blocks {
static var startBlocks = Dictionary()
static var completionBlocks = Dictionary()
}
@@ -24,7 +24,7 @@ extension CAAnimation {
}
set {
Blocks.startBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
@@ -34,25 +34,25 @@ extension CAAnimation {
}
set {
Blocks.completionBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
- public override func animationDidStart(anim: CAAnimation)
+ public func animationDidStart(_ anim: CAAnimation)
{
if let block = self.startBlock {
block()
- Blocks.startBlocks.removeValueForKey(self)
+ Blocks.startBlocks.removeValue(forKey: self)
}
}
- public override func animationDidStop(anim: CAAnimation, finished flag: Bool)
+ public func animationDidStop(_ anim: CAAnimation, finished flag: Bool)
{
if let block = self.completionBlock {
- block(finished: flag)
- Blocks.completionBlocks.removeValueForKey(self)
+ block(flag)
+ Blocks.completionBlocks.removeValue(forKey: self)
}
}
-}
\ No newline at end of file
+}
diff --git a/CustomTransition Demo/CustomTransition/View Controllers/DetailViewController.swift b/CustomTransition Demo/CustomTransition/View Controllers/DetailViewController.swift
index 7d2787a..8d72fba 100644
--- a/CustomTransition Demo/CustomTransition/View Controllers/DetailViewController.swift
+++ b/CustomTransition Demo/CustomTransition/View Controllers/DetailViewController.swift
@@ -15,14 +15,14 @@ class DetailViewController: UIViewController {
override func viewDidLoad()
{
super.viewDidLoad()
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(DetailViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
}
diff --git a/CustomTransition Demo/CustomTransition/View Controllers/PopupViewController.swift b/CustomTransition Demo/CustomTransition/View Controllers/PopupViewController.swift
index 07eaee2..c1c996f 100644
--- a/CustomTransition Demo/CustomTransition/View Controllers/PopupViewController.swift
+++ b/CustomTransition Demo/CustomTransition/View Controllers/PopupViewController.swift
@@ -13,15 +13,15 @@ class PopupViewController: UIViewController {
override func viewDidLoad()
{
super.viewDidLoad()
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(PopupViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
}
diff --git a/CustomTransition Demo/CustomTransition/View Controllers/TransitionsTableViewController.swift b/CustomTransition Demo/CustomTransition/View Controllers/TransitionsTableViewController.swift
index a44e03d..7af4209 100644
--- a/CustomTransition Demo/CustomTransition/View Controllers/TransitionsTableViewController.swift
+++ b/CustomTransition Demo/CustomTransition/View Controllers/TransitionsTableViewController.swift
@@ -10,25 +10,25 @@ import UIKit
class TransitionsTableViewController: UITableViewController {
- override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch (indexPath.row) {
case 0:
- let zoomVC = self.storyboard!.instantiateViewControllerWithIdentifier("detailViewController")
- self.presentViewController(zoomVC, animated: true, completion: nil)
+ let zoomVC = self.storyboard!.instantiateViewController(withIdentifier: "detailViewController")
+ self.present(zoomVC, animated: true, completion: nil)
break
case 1:
- let popupVC = self.storyboard!.instantiateViewControllerWithIdentifier("popupViewController")
- self.presentViewController(popupVC, animated: true, completion: nil)
+ let popupVC = self.storyboard!.instantiateViewController(withIdentifier: "popupViewController")
+ self.present(popupVC, animated: true, completion: nil)
break
case 2:
- let cubeVC = self.storyboard!.instantiateViewControllerWithIdentifier("cubeViewController")
+ let cubeVC = self.storyboard!.instantiateViewController(withIdentifier: "cubeViewController")
self.navigationController?.pushViewController(cubeVC, animated: true)
break
default:
break
}
- tableView.deselectRowAtIndexPath(indexPath, animated: false);
+ tableView.deselectRow(at: indexPath, animated: false);
}
}
diff --git a/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.pbxproj b/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.pbxproj
index 0fd6371..a5d27dc 100644
--- a/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.pbxproj
+++ b/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.pbxproj
@@ -13,15 +13,15 @@
2B528D901BA8F076002F2C59 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2B528D8E1BA8F076002F2C59 /* LaunchScreen.xib */; };
2B528DAE1BA8F795002F2C59 /* TransitionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAD1BA8F795002F2C59 /* TransitionsTableViewController.swift */; };
2B528DB01BA8FAEF002F2C59 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAF1BA8FAEF002F2C59 /* DetailViewController.swift */; };
- 2B55C78A1BADD21A00C3006F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C7891BADD21A00C3006F /* ImageViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2B55C78C1BADD5BA00C3006F /* ImagemAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C78B1BADD5BA00C3006F /* ImagemAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB761BAB9C8A009D972F /* ZoomAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB751BAB9C8A009D972F /* ZoomAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB791BAB9FF2009D972F /* PopupAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB781BAB9FF2009D972F /* PopupAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB7B1BABA476009D972F /* CubeAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7A1BABA476009D972F /* CubeAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
+ 2B55C78A1BADD21A00C3006F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C7891BADD21A00C3006F /* ImageViewController.swift */; };
+ 2B55C78C1BADD5BA00C3006F /* ImagemAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C78B1BADD5BA00C3006F /* ImagemAnimationController.swift */; };
+ 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; };
+ 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; };
+ 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; };
+ 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; };
+ 2BFDAB761BAB9C8A009D972F /* ZoomAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB751BAB9C8A009D972F /* ZoomAnimationController.swift */; };
+ 2BFDAB791BAB9FF2009D972F /* PopupAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB781BAB9FF2009D972F /* PopupAnimationController.swift */; };
+ 2BFDAB7B1BABA476009D972F /* CubeAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7A1BABA476009D972F /* CubeAnimationController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -154,11 +154,12 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
- LastUpgradeCheck = 0700;
+ LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Gian Nucci";
TargetAttributes = {
2B528D7F1BA8F076002F2C59 = {
CreatedOnToolsVersion = 6.4;
+ LastSwiftMigration = 0940;
};
};
};
@@ -243,13 +244,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -288,13 +299,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -313,6 +334,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -327,6 +349,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ciandt.digitalday.CustomTransitionDojo;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -340,6 +364,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ciandt.digitalday.CustomTransitionDojo;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/CustomTransition Dojo 1/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/CustomTransition Dojo 1/CustomTransition/AppDelegate.swift b/CustomTransition Dojo 1/CustomTransition/AppDelegate.swift
index 532e175..6518e29 100644
--- a/CustomTransition Dojo 1/CustomTransition/AppDelegate.swift
+++ b/CustomTransition Dojo 1/CustomTransition/AppDelegate.swift
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
- func applicationWillResignActive(application: UIApplication) {
+ func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- func applicationDidEnterBackground(application: UIApplication) {
+ func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- func applicationWillEnterForeground(application: UIApplication) {
+ func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- func applicationDidBecomeActive(application: UIApplication) {
+ func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- func applicationWillTerminate(application: UIApplication) {
+ func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
diff --git a/CustomTransition Dojo 1/CustomTransition/Base.lproj/LaunchScreen.xib b/CustomTransition Dojo 1/CustomTransition/Base.lproj/LaunchScreen.xib
index 94e825f..c285865 100644
--- a/CustomTransition Dojo 1/CustomTransition/Base.lproj/LaunchScreen.xib
+++ b/CustomTransition Dojo 1/CustomTransition/Base.lproj/LaunchScreen.xib
@@ -1,8 +1,12 @@
-
-
+
+
+
+
+
-
+
+
@@ -24,7 +28,7 @@
-
+
diff --git a/CustomTransition Dojo 1/CustomTransition/CAAnimationBlocks.swift b/CustomTransition Dojo 1/CustomTransition/CAAnimationBlocks.swift
index 0943d52..2247fba 100755
--- a/CustomTransition Dojo 1/CustomTransition/CAAnimationBlocks.swift
+++ b/CustomTransition Dojo 1/CustomTransition/CAAnimationBlocks.swift
@@ -8,12 +8,12 @@
import UIKit
-extension CAAnimation {
+extension CAAnimation: CAAnimationDelegate {
- typealias StartBlock = ((Void) -> Void)
- typealias CompletionBlock = ((finished: Bool) -> Void)
+ typealias StartBlock = (() -> Void)
+ typealias CompletionBlock = ((_ finished: Bool) -> Void)
- private struct Blocks {
+ fileprivate struct Blocks {
static var startBlocks = Dictionary()
static var completionBlocks = Dictionary()
}
@@ -24,7 +24,7 @@ extension CAAnimation {
}
set {
Blocks.startBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
@@ -34,25 +34,24 @@ extension CAAnimation {
}
set {
Blocks.completionBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
-
- public override func animationDidStart(anim: CAAnimation)
+ public func animationDidStart(_ anim: CAAnimation)
{
if let block = self.startBlock {
block()
- Blocks.startBlocks.removeValueForKey(self)
+ Blocks.startBlocks.removeValue(forKey: self)
}
}
- public override func animationDidStop(anim: CAAnimation, finished flag: Bool)
+ public func animationDidStop(_ anim: CAAnimation, finished flag: Bool)
{
if let block = self.completionBlock {
- block(finished: flag)
- Blocks.completionBlocks.removeValueForKey(self)
+ block(flag)
+ Blocks.completionBlocks.removeValue(forKey: self)
}
}
-}
\ No newline at end of file
+}
diff --git a/CustomTransition Dojo 1/CustomTransition/ImageViewController.swift b/CustomTransition Dojo 1/CustomTransition/ImageViewController.swift
index 5d0aae4..6b44c52 100644
--- a/CustomTransition Dojo 1/CustomTransition/ImageViewController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/ImageViewController.swift
@@ -17,16 +17,16 @@ class ImageViewController: UIViewController {
// Do any additional setup after loading the view.
- self.imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("dismiss")))
+ self.imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ImageViewController.dismiss as (ImageViewController) -> () -> ())))
}
- override func viewDidAppear(animated: Bool) {
+ override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
- UIView.animateWithDuration(0.5) { () -> Void in
+ UIView.animate(withDuration: 0.5, animations: { () -> Void in
self.poemaLabel.alpha = 1;
- }
+ })
}
@@ -35,8 +35,8 @@ class ImageViewController: UIViewController {
// Dispose of any resources that can be recreated.
}
- func dismiss() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func dismiss() {
+ self.dismiss(animated: true, completion: nil)
}
/*
diff --git a/CustomTransition Dojo 1/CustomTransition/ImagemAnimationController.swift b/CustomTransition Dojo 1/CustomTransition/ImagemAnimationController.swift
index fb4237b..f6e3c3f 100644
--- a/CustomTransition Dojo 1/CustomTransition/ImagemAnimationController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/ImagemAnimationController.swift
@@ -13,12 +13,12 @@ class ImagemAnimationController: NSObject , UIViewControllerAnimatedTransitionin
var reverseAnimation = false
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 0.4
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
if self.reverseAnimation {
animateOut(transitionContext)
}
@@ -27,85 +27,85 @@ class ImagemAnimationController: NSObject , UIViewControllerAnimatedTransitionin
}
}
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let navigationController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)! as! UINavigationController
+ let navigationController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! as! UINavigationController
let tableViewController = navigationController.topViewController as! TransitionsTableViewController
- let imageViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let imageViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let imageView = imageViewController.view
let tableView = tableViewController.view
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
- let cell = tableViewController.tableView.cellForRowAtIndexPath(NSIndexPath (forRow: 3, inSection: 0));
+ let cell = tableViewController.tableView.cellForRow(at: IndexPath (row: 3, section: 0));
let newImageView = UIImageView(image: cell?.imageView?.image)
- newImageView.frame = (cell?.imageView?.convertRect((cell?.imageView?.bounds)!, toView: navigationController.view))!
+ newImageView.frame = (cell?.imageView?.convert((cell?.imageView?.bounds)!, to: navigationController.view))!
// since the detail view was just built, it needs to be added to the view heirarchy
containerView.addSubview(newImageView)
- containerView.addSubview(imageView)
+ containerView.addSubview(imageView!)
- imageView.frame = containerView.bounds
+ imageView?.frame = containerView.bounds
- imageView.alpha = 0
+ imageView?.alpha = 0
// detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
- UIView.animateWithDuration(duration, delay:0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration, delay:0, options: UIViewAnimationOptions(), animations: { () -> Void in
- imageView.alpha = 1
- newImageView.transform = CGAffineTransformIdentity
+ imageView?.alpha = 1
+ newImageView.transform = CGAffineTransform.identity
newImageView.frame = containerView.bounds
}) { (animationCompleted: Bool) -> Void in
// return the table view back to its original state
- tableView.transform = CGAffineTransformIdentity
+ tableView?.transform = CGAffineTransform.identity
// when the animation is done we need to complete the transition
transitionContext.completeTransition(animationCompleted)
}
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let navigationController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)! as! UINavigationController
+ let navigationController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! as! UINavigationController
let tableViewController = navigationController.topViewController as! TransitionsTableViewController
- let imageViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let imageViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let imageView = imageViewController.view
let tableView = tableViewController.view
- let cell = tableViewController.tableView.cellForRowAtIndexPath(NSIndexPath (forRow: 3, inSection: 0));
+ let cell = tableViewController.tableView.cellForRow(at: IndexPath (row: 3, section: 0));
let newImageView = UIImageView(image: cell?.imageView?.image)
- newImageView.frame = (cell?.imageView?.convertRect((cell?.imageView?.bounds)!, toView: navigationController.view))!
+ newImageView.frame = (cell?.imageView?.convert((cell?.imageView?.bounds)!, to: navigationController.view))!
// since the detail view was just built, it needs to be added to the view heirarchy
- containerView.addSubview(imageView)
+ containerView.addSubview(imageView!)
containerView.addSubview(newImageView)
- newImageView.frame = transitionContext.finalFrameForViewController(tableViewController)
+ newImageView.frame = transitionContext.finalFrame(for: tableViewController)
newImageView.alpha = 0
//tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
- UIView.animateWithDuration(self.transitionDuration(transitionContext), delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
+ UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in
- tableView.alpha = 1
- tableView.transform = CGAffineTransformIdentity
+ tableView?.alpha = 1
+ tableView?.transform = CGAffineTransform.identity
- imageView.alpha = 0
+ imageView?.alpha = 0
//detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
}) { (animationCompleted: Bool) -> Void in
- imageView.alpha = 1
- imageView.transform = CGAffineTransformIdentity
+ imageView?.alpha = 1
+ imageView?.transform = CGAffineTransform.identity
transitionContext.completeTransition(animationCompleted)
}
diff --git a/CustomTransition Dojo 1/CustomTransition/Transitions/CubeAnimationController.swift b/CustomTransition Dojo 1/CustomTransition/Transitions/CubeAnimationController.swift
index 3cb71f1..2948474 100644
--- a/CustomTransition Dojo 1/CustomTransition/Transitions/CubeAnimationController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/Transitions/CubeAnimationController.swift
@@ -10,7 +10,7 @@ import UIKit
class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewControllerAnimatedTransitioning, UIGestureRecognizerDelegate {
// constants
- let Rotation = CGFloat(M_PI_2)
+ let Rotation = CGFloat(Double.pi/2)
let Projection: CGFloat = 1 / -600
let Duration: CFTimeInterval = 0.65
@@ -21,25 +21,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// interactive transition properties
var interactive = false
var startTouchPoint: CGPoint?
- var animationTimer: NSTimer?
+ var animationTimer: Timer?
//MARK: - UIViewControllerAnimatedTransitioning
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return Duration
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
self.transitionContext = transitionContext
- let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let (containerView, sourceView, destinationView) = self.transitionContextViews(transitionContext)
// since the detail view was just built, it needs to be added to the view heirarchy
containerView.addSubview(destinationView)
- destinationView.frame = transitionContext.finalFrameForViewController(toViewController)
+ destinationView.frame = transitionContext.finalFrame(for: toViewController)
// setup the 3D scene by setting perspective in the container and configurin the view positions
self.setupScene(containerView, sourceView: sourceView, destinationView: destinationView)
@@ -60,15 +60,15 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
destinationViewAnimation.completionBlock = { (success: Bool) -> Void in
// whenever this animation completes we need to update the context and determine
// if the transition successfully completed.
- transitionContext.completeTransition(success && !transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(success && !transitionContext.transitionWasCancelled)
}
- sourceView.layer.addAnimation(sourceViewAnimation, forKey: sourceViewAnimation.keyPath)
- destinationView.layer.addAnimation(destinationViewAnimation, forKey: destinationViewAnimation.keyPath)
+ sourceView.layer.add(sourceViewAnimation, forKey: sourceViewAnimation.keyPath)
+ destinationView.layer.add(destinationViewAnimation, forKey: destinationViewAnimation.keyPath)
}
- func animationEnded(transitionCompleted: Bool)
+ func animationEnded(_ transitionCompleted: Bool)
{
self.transitionContext = nil
self.interactive = false
@@ -78,29 +78,29 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - UIViewControllerInteractiveTransitioning
- override func startInteractiveTransition(transitionContext: UIViewControllerContextTransitioning)
+ override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning)
{
super.startInteractiveTransition(transitionContext)
// the gesture has already began once this method fires, so we cannot rely on the Begin state for the
// gesture to record the first touch point. instead, capture it here when the interactive transition begins.
- self.startTouchPoint = self.interactivePopGestureRecognizer?.locationInView(transitionContext.containerView())
+ self.startTouchPoint = self.interactivePopGestureRecognizer?.location(in: transitionContext.containerView)
}
- override func cancelInteractiveTransition() {
- super.cancelInteractiveTransition()
+ override func cancel() {
+ super.cancel()
// here we need to reset the layer properties for our views to their original values.
// by doing this, we fix an animation flicker that shows the views in their final state
let transitionContext = self.transitionContext!
let (_, sourceView, destinationView) = self.transitionContextViews(transitionContext)
- let sourceViewAnimation = sourceView.layer.animationForKey("transform") as! CABasicAnimation
- let destinationViewAnimation = destinationView.layer.animationForKey("transform") as! CABasicAnimation
+ let sourceViewAnimation = sourceView.layer.animation(forKey: "transform") as! CABasicAnimation
+ let destinationViewAnimation = destinationView.layer.animation(forKey: "transform") as! CABasicAnimation
- sourceView.layer.transform = (sourceViewAnimation.fromValue as! NSValue).CATransform3DValue
- destinationView.layer.transform = (destinationViewAnimation.fromValue as! NSValue).CATransform3DValue
+ sourceView.layer.transform = (sourceViewAnimation.fromValue as! NSValue).caTransform3DValue
+ destinationView.layer.transform = (destinationViewAnimation.fromValue as! NSValue).caTransform3DValue
}
@@ -111,12 +111,12 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
var interactivePopGestureRecognizer: UIGestureRecognizer? {
didSet {
self.interactivePopGestureRecognizer?.delegate = self
- self.interactivePopGestureRecognizer?.addTarget(self, action: "screenEdgeDidPan:")
+ self.interactivePopGestureRecognizer?.addTarget(self, action: #selector(CubeAnimationController.screenEdgeDidPan(_:)))
}
}
- func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool
+ func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
{
// prevent the gesture from starting when we're in the middle of animating
// to a new target value.
@@ -133,25 +133,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
}
- func screenEdgeDidPan(gesture: UIGestureRecognizer)
+ @objc func screenEdgeDidPan(_ gesture: UIGestureRecognizer)
{
if let transitionContext = self.transitionContext {
- let containerView = transitionContext.containerView()
- let touchPoint = gesture.locationInView(containerView)
- let progress = touchPoint.x / CGRectGetWidth(containerView!.frame)
+ let containerView = transitionContext.containerView
+ let touchPoint = gesture.location(in: containerView)
+ let progress = touchPoint.x / containerView.frame.width
switch (gesture.state) {
- case .Changed:
- self.updateInteractiveTransition(progress)
+ case .changed:
+ self.update(progress)
if progress >= 0.995 {
- self.finishInteractiveTransition()
+ self.finish()
}
break
- case .Ended, .Cancelled:
+ case .ended, .cancelled:
// when a gesture ends, we need to determine how far through the user
// was through the animation, and then advance our animation to either a
@@ -174,10 +174,10 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - Animation Timer
- func animateToPercentComplete(percent: CGFloat)
+ func animateToPercentComplete(_ percent: CGFloat)
{
if self.animationTimer == nil {
- self.animationTimer = NSTimer.scheduledTimerWithTimeInterval(1/60, target: self, selector: "adjustPercentComplete:", userInfo: Float(percent), repeats: true)
+ self.animationTimer = Timer.scheduledTimer(timeInterval: 1/60, target: self, selector: #selector(CubeAnimationController.adjustPercentComplete(_:)), userInfo: Float(percent), repeats: true)
}
}
@@ -189,22 +189,22 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
}
- func adjustPercentComplete(timer: NSTimer)
+ @objc func adjustPercentComplete(_ timer: Timer)
{
let targetPercent = timer.userInfo as! CGFloat
let delta = (targetPercent - self.percentComplete) * 0.1
- self.updateInteractiveTransition(self.percentComplete + delta)
+ self.update(self.percentComplete + delta)
if abs(delta) < 0.0001 {
self.stopAnimationTimer()
if targetPercent == 1 {
- self.finishInteractiveTransition()
+ self.finish()
}
else {
- self.cancelInteractiveTransition()
+ self.cancel()
}
}
}
@@ -213,14 +213,14 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - Helpers
// helper method to retrieve the contents of the transition context
- func transitionContextViews(transitionContext: UIViewControllerContextTransitioning) -> (containerView: UIView, sourceView: UIView, destinationView: UIView)
+ func transitionContextViews(_ transitionContext: UIViewControllerContextTransitioning) -> (containerView: UIView, sourceView: UIView, destinationView: UIView)
{
- let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
- let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- return (transitionContext.containerView()!, fromViewController.view, toViewController.view)
+ let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
+ let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ return (transitionContext.containerView, fromViewController.view, toViewController.view)
}
- func setupScene(containerView: UIView, sourceView: UIView, destinationView: UIView)
+ func setupScene(_ containerView: UIView, sourceView: UIView, destinationView: UIView)
{
// setup the 3D scene by setting perspective in the container and configuring the view positions
// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW13
@@ -230,25 +230,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// calculate the z-distance as a ratio of the width of the container.
// this keeps the edges of the cube sides aligned when rotating with different screen sizes
- let z = -(0.5 * CGRectGetWidth(self.transitionContext!.containerView()!.frame))
+ let z = -(0.5 * self.transitionContext!.containerView.frame.width)
sourceView.layer.zPosition = z
sourceView.layer.anchorPointZ = z
destinationView.layer.zPosition = z
destinationView.layer.anchorPointZ = z
}
- func createCubeTransformAnimation(rotation: CGFloat, view: UIView, presenting: Bool) -> CABasicAnimation
+ func createCubeTransformAnimation(_ rotation: CGFloat, view: UIView, presenting: Bool) -> CABasicAnimation
{
let viewFromTransform = CATransform3DMakeRotation(rotation, 0, 1, 0)
let transformAnimation = CABasicAnimation(keyPath: "transform")
if presenting {
- transformAnimation.fromValue = NSValue(CATransform3D: viewFromTransform)
- transformAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity)
+ transformAnimation.fromValue = NSValue(caTransform3D: viewFromTransform)
+ transformAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
}
else {
- transformAnimation.fromValue = NSValue(CATransform3D: CATransform3DIdentity)
- transformAnimation.toValue = NSValue(CATransform3D: viewFromTransform)
+ transformAnimation.fromValue = NSValue(caTransform3D: CATransform3DIdentity)
+ transformAnimation.toValue = NSValue(caTransform3D: viewFromTransform)
}
transformAnimation.duration = Duration
@@ -258,7 +258,7 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// set the view's layer to the final value. fixes flickering at the end of the animation
- view.layer.transform = (transformAnimation.toValue as! NSValue).CATransform3DValue
+ view.layer.transform = (transformAnimation.toValue as! NSValue).caTransform3DValue
return transformAnimation
}
diff --git a/CustomTransition Dojo 1/CustomTransition/Transitions/PopupAnimationController.swift b/CustomTransition Dojo 1/CustomTransition/Transitions/PopupAnimationController.swift
index 90b545b..ef93462 100644
--- a/CustomTransition Dojo 1/CustomTransition/Transitions/PopupAnimationController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/Transitions/PopupAnimationController.swift
@@ -12,19 +12,19 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
var reverseAnimation: Bool = false
lazy var dimmerView: UIView = {
- let view = UIView(frame: CGRectZero)
- view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.8)
+ let view = UIView(frame: CGRect.zero)
+ view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
return view
}()
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 1.25
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -34,19 +34,19 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
}
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let duration = self.transitionDuration(transitionContext)
- let containerView = transitionContext.containerView()
- let popupViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let duration = self.transitionDuration(using: transitionContext)
+ let containerView = transitionContext.containerView
+ let popupViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let popupView = popupViewController.view
let popupSize = popupViewController.preferredContentSize
let scaleValues: [NSValue] = [
- NSValue(CATransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, -500, 0), 0, 0, 1)),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.75, 1), 0, 200, 0)),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(0.8, 1.3, 1), 0, -55, 0)),
- NSValue(CATransform3D: CATransform3DIdentity)
+ NSValue(caTransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, -500, 0), 0, 0, 1)),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.75, 1), 0, 200, 0)),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(0.8, 1.3, 1), 0, -55, 0)),
+ NSValue(caTransform3D: CATransform3DIdentity)
]
let transformAnimation = CAKeyframeAnimation(keyPath: "transform")
@@ -72,36 +72,36 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
dimmerFadeAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
dimmerFadeAnimation.completionBlock = { (finished: Bool) -> Void in
if finished {
- containerView!.addSubview(popupView)
+ containerView.addSubview(popupView!)
// set the layer to its final value before adding the animation
- popupView.layer.transform = CATransform3DIdentity
+ popupView?.layer.transform = CATransform3DIdentity
- popupView.layer.addAnimation(transformAnimation, forKey: "transformAnimation")
+ popupView?.layer.add(transformAnimation, forKey: "transformAnimation")
}
else {
transitionContext.completeTransition(finished)
}
}
- popupView.frame = CGRect(origin: CGPointZero, size: popupSize)
- popupView.center = containerView!.center
+ popupView?.frame = CGRect(origin: CGPoint.zero, size: popupSize)
+ popupView?.center = containerView.center
// display the dimmer
- containerView!.addSubview(self.dimmerView)
- self.dimmerView.frame = containerView!.bounds
+ containerView.addSubview(self.dimmerView)
+ self.dimmerView.frame = containerView.bounds
// set the layer to its final value before adding the animation
self.dimmerView.layer.opacity = 1
- self.dimmerView.layer.addAnimation(dimmerFadeAnimation, forKey: "dimmerFadeAnimation")
+ self.dimmerView.layer.add(dimmerFadeAnimation, forKey: "dimmerFadeAnimation")
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let duration = self.transitionDuration(transitionContext)
- let popupViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let duration = self.transitionDuration(using: transitionContext)
+ let popupViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let popupView = popupViewController.view
let dimmerFadeAnimation = CABasicAnimation(keyPath: "opacity")
@@ -115,9 +115,9 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
let scaleValues: [NSValue] = [
- NSValue(CATransform3D: CATransform3DIdentity),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.9, 1), 0, -100, 0)),
- NSValue(CATransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, 500, 0), 0, 0.5, 1)),
+ NSValue(caTransform3D: CATransform3DIdentity),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.9, 1), 0, -100, 0)),
+ NSValue(caTransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, 500, 0), 0, 0.5, 1)),
]
let transformAnimation = CAKeyframeAnimation(keyPath: "transform")
@@ -132,7 +132,7 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
transformAnimation.completionBlock = { (finished: Bool) -> Void in
if finished {
self.dimmerView.layer.opacity = 0
- self.dimmerView.layer.addAnimation(dimmerFadeAnimation, forKey: "fadeAnimation")
+ self.dimmerView.layer.add(dimmerFadeAnimation, forKey: "fadeAnimation")
}
else {
transitionContext.completeTransition(finished)
@@ -141,8 +141,8 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
// its important to set the layer to its final values when adding the animation, without this,
// you can get a flicker showing the original values when the animation ends.
- popupView.layer.transform = scaleValues.last!.CATransform3DValue
- popupView.layer.addAnimation(transformAnimation, forKey: "transformAnimation")
+ popupView?.layer.transform = scaleValues.last!.caTransform3DValue
+ popupView?.layer.add(transformAnimation, forKey: "transformAnimation")
}
}
diff --git a/CustomTransition Dojo 1/CustomTransition/Transitions/ZoomAnimationController.swift b/CustomTransition Dojo 1/CustomTransition/Transitions/ZoomAnimationController.swift
index e8f419c..68f3dbb 100644
--- a/CustomTransition Dojo 1/CustomTransition/Transitions/ZoomAnimationController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/Transitions/ZoomAnimationController.swift
@@ -9,7 +9,7 @@
import UIKit
class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
- private struct Zoom
+ fileprivate struct Zoom
{
static let minimum: CGFloat = 0.1, maximum: CGFloat = 5.0
}
@@ -19,13 +19,13 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
//MARK: -
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 0.4
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -37,34 +37,34 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
//MARK: - Animations
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
- let detailViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
+ let detailViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let detailView = detailViewController.view
let tableView = tableViewController.view
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
// since the detail view was just built, it needs to be added to the view heirarchy
- containerView.addSubview(detailView)
- detailView.frame = containerView.bounds
+ containerView.addSubview(detailView!)
+ detailView?.frame = containerView.bounds
- detailView.alpha = 0
- detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
+ detailView?.alpha = 0
+ detailView?.transform = CGAffineTransform(scaleX: Zoom.maximum, y: Zoom.maximum)
- UIView.animateWithDuration(duration, delay:0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration, delay:0, options: UIViewAnimationOptions(), animations: { () -> Void in
- detailView.alpha = 1
- detailView.transform = CGAffineTransformIdentity
- tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
+ detailView?.alpha = 1
+ detailView?.transform = CGAffineTransform.identity
+ tableView?.transform = CGAffineTransform(scaleX: Zoom.minimum, y: Zoom.minimum)
}) { (animationCompleted: Bool) -> Void in
// return the table view back to its original state
- tableView.transform = CGAffineTransformIdentity
+ tableView?.transform = CGAffineTransform.identity
// when the animation is done we need to complete the transition
transitionContext.completeTransition(animationCompleted)
@@ -72,30 +72,30 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- let detailViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ let detailViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let detailView = detailViewController.view
let tableView = tableViewController.view
- tableView.frame = transitionContext.finalFrameForViewController(tableViewController)
- tableView.alpha = 0
- tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
+ tableView?.frame = transitionContext.finalFrame(for: tableViewController)
+ tableView?.alpha = 0
+ tableView?.transform = CGAffineTransform(scaleX: Zoom.minimum, y: Zoom.minimum)
- UIView.animateWithDuration(self.transitionDuration(transitionContext), delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
+ UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in
- tableView.alpha = 1
- tableView.transform = CGAffineTransformIdentity
+ tableView?.alpha = 1
+ tableView?.transform = CGAffineTransform.identity
- detailView.alpha = 0
- detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
+ detailView?.alpha = 0
+ detailView?.transform = CGAffineTransform(scaleX: Zoom.maximum, y: Zoom.maximum)
}) { (animationCompleted: Bool) -> Void in
- detailView.alpha = 1
- detailView.transform = CGAffineTransformIdentity
+ detailView?.alpha = 1
+ detailView?.transform = CGAffineTransform.identity
transitionContext.completeTransition(animationCompleted)
}
diff --git a/CustomTransition Dojo 1/CustomTransition/View Controllers/DetailViewController.swift b/CustomTransition Dojo 1/CustomTransition/View Controllers/DetailViewController.swift
index 7d2787a..8d72fba 100644
--- a/CustomTransition Dojo 1/CustomTransition/View Controllers/DetailViewController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/View Controllers/DetailViewController.swift
@@ -15,14 +15,14 @@ class DetailViewController: UIViewController {
override func viewDidLoad()
{
super.viewDidLoad()
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(DetailViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
}
diff --git a/CustomTransition Dojo 1/CustomTransition/View Controllers/PopupViewController.swift b/CustomTransition Dojo 1/CustomTransition/View Controllers/PopupViewController.swift
index bb2377f..32ddd2c 100644
--- a/CustomTransition Dojo 1/CustomTransition/View Controllers/PopupViewController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/View Controllers/PopupViewController.swift
@@ -17,25 +17,25 @@ class PopupViewController: UIViewController, UIViewControllerTransitioningDelega
self.preferredContentSize = CGSize(width: 200, height: 100)
self.view.clipsToBounds = true
self.view.layer.cornerRadius = 4
- self.view.layer.borderColor = UIColor.darkGrayColor().CGColor
+ self.view.layer.borderColor = UIColor.darkGray.cgColor
self.view.layer.borderWidth = 1
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(PopupViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
required init?(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
self.transitioningDelegate = self
- self.modalPresentationStyle = .Custom
+ self.modalPresentationStyle = .custom
}
@@ -43,13 +43,13 @@ class PopupViewController: UIViewController, UIViewControllerTransitioningDelega
lazy var popupAnimation = PopupAnimationController()
- func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.popupAnimation.reverseAnimation = false
return self.popupAnimation
}
- func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.popupAnimation.reverseAnimation = true
return self.popupAnimation
diff --git a/CustomTransition Dojo 1/CustomTransition/View Controllers/TransitionsTableViewController.swift b/CustomTransition Dojo 1/CustomTransition/View Controllers/TransitionsTableViewController.swift
index fbdf29c..c9f2fba 100644
--- a/CustomTransition Dojo 1/CustomTransition/View Controllers/TransitionsTableViewController.swift
+++ b/CustomTransition Dojo 1/CustomTransition/View Controllers/TransitionsTableViewController.swift
@@ -10,33 +10,33 @@ import UIKit
class TransitionsTableViewController: UITableViewController, UIViewControllerTransitioningDelegate, UINavigationControllerDelegate {
- override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch (indexPath.row) {
case 0:
- let zoomVC = self.storyboard!.instantiateViewControllerWithIdentifier("detailViewController")
+ let zoomVC = self.storyboard!.instantiateViewController(withIdentifier: "detailViewController")
zoomVC.transitioningDelegate = self
- zoomVC.modalPresentationStyle = .Custom
- self.presentViewController(zoomVC, animated: true, completion: nil)
+ zoomVC.modalPresentationStyle = .custom
+ self.present(zoomVC, animated: true, completion: nil)
break
case 1:
- let popupVC = self.storyboard!.instantiateViewControllerWithIdentifier("popupViewController")
- self.presentViewController(popupVC, animated: true, completion: nil)
+ let popupVC = self.storyboard!.instantiateViewController(withIdentifier: "popupViewController")
+ self.present(popupVC, animated: true, completion: nil)
break
case 2:
- let cubeVC = self.storyboard!.instantiateViewControllerWithIdentifier("cubeViewController")
+ let cubeVC = self.storyboard!.instantiateViewController(withIdentifier: "cubeViewController")
self.navigationController?.delegate = self
self.navigationController?.pushViewController(cubeVC, animated: true)
break
case 3:
- let imgVC = self.storyboard!.instantiateViewControllerWithIdentifier("ImageViewController")
+ let imgVC = self.storyboard!.instantiateViewController(withIdentifier: "ImageViewController")
imgVC.transitioningDelegate = self
- imgVC.modalPresentationStyle = .Custom
- self.presentViewController(imgVC, animated: true, completion: nil)
+ imgVC.modalPresentationStyle = .custom
+ self.present(imgVC, animated: true, completion: nil)
default:
break
}
- tableView.deselectRowAtIndexPath(indexPath, animated: false);
+ tableView.deselectRow(at: indexPath, animated: false);
}
//MARK: -
@@ -45,12 +45,12 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
lazy var zoomAnimation = ZoomAnimationController()
lazy var cubeAnimation = CubeAnimationController()
- func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
- if presented.isKindOfClass(DetailViewController) {
+ if presented.isKind(of: DetailViewController.self) {
self.zoomAnimation.reverseAnimation = false
return self.zoomAnimation
- } else if presented.isKindOfClass(ImageViewController) {
+ } else if presented.isKind(of: ImageViewController.self) {
self.imageAnimation.reverseAnimation = false
return self.imageAnimation
}
@@ -58,12 +58,12 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
return nil
}
- func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
- if dismissed.isKindOfClass(DetailViewController) {
+ if dismissed.isKind(of: DetailViewController.self) {
self.zoomAnimation.reverseAnimation = true
return self.zoomAnimation
- } else if dismissed.isKindOfClass(ImageViewController) {
+ } else if dismissed.isKind(of: ImageViewController.self) {
self.imageAnimation.reverseAnimation = true
return self.imageAnimation
}
@@ -73,11 +73,11 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
//MARK: - UINavigationControllerDelegate
- func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
switch (operation) {
- case .Pop:
+ case .pop:
self.cubeAnimation.reverseAnimation = true
break
@@ -92,7 +92,7 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
return self.cubeAnimation
}
- func navigationController(navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
+ func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
{
if self.cubeAnimation.interactive {
return self.cubeAnimation
diff --git a/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.pbxproj b/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.pbxproj
index 6346954..5dfafc5 100644
--- a/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.pbxproj
+++ b/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.pbxproj
@@ -13,15 +13,15 @@
2B528D901BA8F076002F2C59 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2B528D8E1BA8F076002F2C59 /* LaunchScreen.xib */; };
2B528DAE1BA8F795002F2C59 /* TransitionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAD1BA8F795002F2C59 /* TransitionsTableViewController.swift */; };
2B528DB01BA8FAEF002F2C59 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B528DAF1BA8FAEF002F2C59 /* DetailViewController.swift */; };
- 2B55C78E1BADE96A00C3006F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C78D1BADE96A00C3006F /* ImageViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2B55C7901BADEE4C00C3006F /* ImageAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C78F1BADEE4C00C3006F /* ImageAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB761BAB9C8A009D972F /* ZoomAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB751BAB9C8A009D972F /* ZoomAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB791BAB9FF2009D972F /* PopupAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB781BAB9FF2009D972F /* PopupAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
- 2BFDAB7B1BABA476009D972F /* CubeAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7A1BABA476009D972F /* CubeAnimationController.swift */; settings = {ASSET_TAGS = (); }; };
+ 2B55C78E1BADE96A00C3006F /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C78D1BADE96A00C3006F /* ImageViewController.swift */; };
+ 2B55C7901BADEE4C00C3006F /* ImageAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B55C78F1BADEE4C00C3006F /* ImageAnimationController.swift */; };
+ 2BFDAB651BAAFDCA009D972F /* PopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB641BAAFDCA009D972F /* PopupViewController.swift */; };
+ 2BFDAB671BAAFDE6009D972F /* CubeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB661BAAFDE6009D972F /* CubeViewController.swift */; };
+ 2BFDAB6B1BAB03CB009D972F /* balloons.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BFDAB6A1BAB03CB009D972F /* balloons.png */; };
+ 2BFDAB721BAB1599009D972F /* CAAnimationBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB711BAB1599009D972F /* CAAnimationBlocks.swift */; };
+ 2BFDAB761BAB9C8A009D972F /* ZoomAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB751BAB9C8A009D972F /* ZoomAnimationController.swift */; };
+ 2BFDAB791BAB9FF2009D972F /* PopupAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB781BAB9FF2009D972F /* PopupAnimationController.swift */; };
+ 2BFDAB7B1BABA476009D972F /* CubeAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BFDAB7A1BABA476009D972F /* CubeAnimationController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -154,11 +154,13 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
- LastUpgradeCheck = 0700;
+ LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Gian Nucci";
TargetAttributes = {
2B528D7F1BA8F076002F2C59 = {
CreatedOnToolsVersion = 6.4;
+ LastSwiftMigration = 0940;
+ ProvisioningStyle = Manual;
};
};
};
@@ -243,13 +245,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -288,13 +300,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -313,6 +335,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -322,11 +345,16 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Manual;
+ DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = CustomTransition/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ciandt.digitalday.CustomTransitionDojo;
PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -335,11 +363,16 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Manual;
+ DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = CustomTransition/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ciandt.digitalday.CustomTransitionDojo;
PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/CustomTransition Dojo 2/CustomTransition.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/CustomTransition Dojo 2/CustomTransition/AppDelegate.swift b/CustomTransition Dojo 2/CustomTransition/AppDelegate.swift
index 532e175..6518e29 100644
--- a/CustomTransition Dojo 2/CustomTransition/AppDelegate.swift
+++ b/CustomTransition Dojo 2/CustomTransition/AppDelegate.swift
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
- func applicationWillResignActive(application: UIApplication) {
+ func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- func applicationDidEnterBackground(application: UIApplication) {
+ func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- func applicationWillEnterForeground(application: UIApplication) {
+ func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- func applicationDidBecomeActive(application: UIApplication) {
+ func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- func applicationWillTerminate(application: UIApplication) {
+ func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
diff --git a/CustomTransition Dojo 2/CustomTransition/CAAnimationBlocks.swift b/CustomTransition Dojo 2/CustomTransition/CAAnimationBlocks.swift
index 0943d52..3a05b73 100755
--- a/CustomTransition Dojo 2/CustomTransition/CAAnimationBlocks.swift
+++ b/CustomTransition Dojo 2/CustomTransition/CAAnimationBlocks.swift
@@ -8,12 +8,12 @@
import UIKit
-extension CAAnimation {
+extension CAAnimation: CAAnimationDelegate {
- typealias StartBlock = ((Void) -> Void)
- typealias CompletionBlock = ((finished: Bool) -> Void)
+ typealias StartBlock = (() -> Void)
+ typealias CompletionBlock = ((_ finished: Bool) -> Void)
- private struct Blocks {
+ fileprivate struct Blocks {
static var startBlocks = Dictionary()
static var completionBlocks = Dictionary()
}
@@ -24,7 +24,7 @@ extension CAAnimation {
}
set {
Blocks.startBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
@@ -34,25 +34,25 @@ extension CAAnimation {
}
set {
Blocks.completionBlocks[self] = newValue
- self.delegate = self
+ self.delegate = (self as CAAnimationDelegate)
}
}
- public override func animationDidStart(anim: CAAnimation)
+ public func animationDidStart(_ anim: CAAnimation)
{
if let block = self.startBlock {
block()
- Blocks.startBlocks.removeValueForKey(self)
+ Blocks.startBlocks.removeValue(forKey: self)
}
}
- public override func animationDidStop(anim: CAAnimation, finished flag: Bool)
+ public func animationDidStop(_ anim: CAAnimation, finished flag: Bool)
{
if let block = self.completionBlock {
- block(finished: flag)
- Blocks.completionBlocks.removeValueForKey(self)
+ block(flag)
+ Blocks.completionBlocks.removeValue(forKey: self)
}
}
-}
\ No newline at end of file
+}
diff --git a/CustomTransition Dojo 2/CustomTransition/Transitions/CubeAnimationController.swift b/CustomTransition Dojo 2/CustomTransition/Transitions/CubeAnimationController.swift
index 3cb71f1..2948474 100644
--- a/CustomTransition Dojo 2/CustomTransition/Transitions/CubeAnimationController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/Transitions/CubeAnimationController.swift
@@ -10,7 +10,7 @@ import UIKit
class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewControllerAnimatedTransitioning, UIGestureRecognizerDelegate {
// constants
- let Rotation = CGFloat(M_PI_2)
+ let Rotation = CGFloat(Double.pi/2)
let Projection: CGFloat = 1 / -600
let Duration: CFTimeInterval = 0.65
@@ -21,25 +21,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// interactive transition properties
var interactive = false
var startTouchPoint: CGPoint?
- var animationTimer: NSTimer?
+ var animationTimer: Timer?
//MARK: - UIViewControllerAnimatedTransitioning
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return Duration
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
self.transitionContext = transitionContext
- let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let (containerView, sourceView, destinationView) = self.transitionContextViews(transitionContext)
// since the detail view was just built, it needs to be added to the view heirarchy
containerView.addSubview(destinationView)
- destinationView.frame = transitionContext.finalFrameForViewController(toViewController)
+ destinationView.frame = transitionContext.finalFrame(for: toViewController)
// setup the 3D scene by setting perspective in the container and configurin the view positions
self.setupScene(containerView, sourceView: sourceView, destinationView: destinationView)
@@ -60,15 +60,15 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
destinationViewAnimation.completionBlock = { (success: Bool) -> Void in
// whenever this animation completes we need to update the context and determine
// if the transition successfully completed.
- transitionContext.completeTransition(success && !transitionContext.transitionWasCancelled())
+ transitionContext.completeTransition(success && !transitionContext.transitionWasCancelled)
}
- sourceView.layer.addAnimation(sourceViewAnimation, forKey: sourceViewAnimation.keyPath)
- destinationView.layer.addAnimation(destinationViewAnimation, forKey: destinationViewAnimation.keyPath)
+ sourceView.layer.add(sourceViewAnimation, forKey: sourceViewAnimation.keyPath)
+ destinationView.layer.add(destinationViewAnimation, forKey: destinationViewAnimation.keyPath)
}
- func animationEnded(transitionCompleted: Bool)
+ func animationEnded(_ transitionCompleted: Bool)
{
self.transitionContext = nil
self.interactive = false
@@ -78,29 +78,29 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - UIViewControllerInteractiveTransitioning
- override func startInteractiveTransition(transitionContext: UIViewControllerContextTransitioning)
+ override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning)
{
super.startInteractiveTransition(transitionContext)
// the gesture has already began once this method fires, so we cannot rely on the Begin state for the
// gesture to record the first touch point. instead, capture it here when the interactive transition begins.
- self.startTouchPoint = self.interactivePopGestureRecognizer?.locationInView(transitionContext.containerView())
+ self.startTouchPoint = self.interactivePopGestureRecognizer?.location(in: transitionContext.containerView)
}
- override func cancelInteractiveTransition() {
- super.cancelInteractiveTransition()
+ override func cancel() {
+ super.cancel()
// here we need to reset the layer properties for our views to their original values.
// by doing this, we fix an animation flicker that shows the views in their final state
let transitionContext = self.transitionContext!
let (_, sourceView, destinationView) = self.transitionContextViews(transitionContext)
- let sourceViewAnimation = sourceView.layer.animationForKey("transform") as! CABasicAnimation
- let destinationViewAnimation = destinationView.layer.animationForKey("transform") as! CABasicAnimation
+ let sourceViewAnimation = sourceView.layer.animation(forKey: "transform") as! CABasicAnimation
+ let destinationViewAnimation = destinationView.layer.animation(forKey: "transform") as! CABasicAnimation
- sourceView.layer.transform = (sourceViewAnimation.fromValue as! NSValue).CATransform3DValue
- destinationView.layer.transform = (destinationViewAnimation.fromValue as! NSValue).CATransform3DValue
+ sourceView.layer.transform = (sourceViewAnimation.fromValue as! NSValue).caTransform3DValue
+ destinationView.layer.transform = (destinationViewAnimation.fromValue as! NSValue).caTransform3DValue
}
@@ -111,12 +111,12 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
var interactivePopGestureRecognizer: UIGestureRecognizer? {
didSet {
self.interactivePopGestureRecognizer?.delegate = self
- self.interactivePopGestureRecognizer?.addTarget(self, action: "screenEdgeDidPan:")
+ self.interactivePopGestureRecognizer?.addTarget(self, action: #selector(CubeAnimationController.screenEdgeDidPan(_:)))
}
}
- func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool
+ func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
{
// prevent the gesture from starting when we're in the middle of animating
// to a new target value.
@@ -133,25 +133,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
}
- func screenEdgeDidPan(gesture: UIGestureRecognizer)
+ @objc func screenEdgeDidPan(_ gesture: UIGestureRecognizer)
{
if let transitionContext = self.transitionContext {
- let containerView = transitionContext.containerView()
- let touchPoint = gesture.locationInView(containerView)
- let progress = touchPoint.x / CGRectGetWidth(containerView!.frame)
+ let containerView = transitionContext.containerView
+ let touchPoint = gesture.location(in: containerView)
+ let progress = touchPoint.x / containerView.frame.width
switch (gesture.state) {
- case .Changed:
- self.updateInteractiveTransition(progress)
+ case .changed:
+ self.update(progress)
if progress >= 0.995 {
- self.finishInteractiveTransition()
+ self.finish()
}
break
- case .Ended, .Cancelled:
+ case .ended, .cancelled:
// when a gesture ends, we need to determine how far through the user
// was through the animation, and then advance our animation to either a
@@ -174,10 +174,10 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - Animation Timer
- func animateToPercentComplete(percent: CGFloat)
+ func animateToPercentComplete(_ percent: CGFloat)
{
if self.animationTimer == nil {
- self.animationTimer = NSTimer.scheduledTimerWithTimeInterval(1/60, target: self, selector: "adjustPercentComplete:", userInfo: Float(percent), repeats: true)
+ self.animationTimer = Timer.scheduledTimer(timeInterval: 1/60, target: self, selector: #selector(CubeAnimationController.adjustPercentComplete(_:)), userInfo: Float(percent), repeats: true)
}
}
@@ -189,22 +189,22 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
}
- func adjustPercentComplete(timer: NSTimer)
+ @objc func adjustPercentComplete(_ timer: Timer)
{
let targetPercent = timer.userInfo as! CGFloat
let delta = (targetPercent - self.percentComplete) * 0.1
- self.updateInteractiveTransition(self.percentComplete + delta)
+ self.update(self.percentComplete + delta)
if abs(delta) < 0.0001 {
self.stopAnimationTimer()
if targetPercent == 1 {
- self.finishInteractiveTransition()
+ self.finish()
}
else {
- self.cancelInteractiveTransition()
+ self.cancel()
}
}
}
@@ -213,14 +213,14 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
//MARK: - Helpers
// helper method to retrieve the contents of the transition context
- func transitionContextViews(transitionContext: UIViewControllerContextTransitioning) -> (containerView: UIView, sourceView: UIView, destinationView: UIView)
+ func transitionContextViews(_ transitionContext: UIViewControllerContextTransitioning) -> (containerView: UIView, sourceView: UIView, destinationView: UIView)
{
- let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
- let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- return (transitionContext.containerView()!, fromViewController.view, toViewController.view)
+ let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
+ let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ return (transitionContext.containerView, fromViewController.view, toViewController.view)
}
- func setupScene(containerView: UIView, sourceView: UIView, destinationView: UIView)
+ func setupScene(_ containerView: UIView, sourceView: UIView, destinationView: UIView)
{
// setup the 3D scene by setting perspective in the container and configuring the view positions
// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW13
@@ -230,25 +230,25 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// calculate the z-distance as a ratio of the width of the container.
// this keeps the edges of the cube sides aligned when rotating with different screen sizes
- let z = -(0.5 * CGRectGetWidth(self.transitionContext!.containerView()!.frame))
+ let z = -(0.5 * self.transitionContext!.containerView.frame.width)
sourceView.layer.zPosition = z
sourceView.layer.anchorPointZ = z
destinationView.layer.zPosition = z
destinationView.layer.anchorPointZ = z
}
- func createCubeTransformAnimation(rotation: CGFloat, view: UIView, presenting: Bool) -> CABasicAnimation
+ func createCubeTransformAnimation(_ rotation: CGFloat, view: UIView, presenting: Bool) -> CABasicAnimation
{
let viewFromTransform = CATransform3DMakeRotation(rotation, 0, 1, 0)
let transformAnimation = CABasicAnimation(keyPath: "transform")
if presenting {
- transformAnimation.fromValue = NSValue(CATransform3D: viewFromTransform)
- transformAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity)
+ transformAnimation.fromValue = NSValue(caTransform3D: viewFromTransform)
+ transformAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
}
else {
- transformAnimation.fromValue = NSValue(CATransform3D: CATransform3DIdentity)
- transformAnimation.toValue = NSValue(CATransform3D: viewFromTransform)
+ transformAnimation.fromValue = NSValue(caTransform3D: CATransform3DIdentity)
+ transformAnimation.toValue = NSValue(caTransform3D: viewFromTransform)
}
transformAnimation.duration = Duration
@@ -258,7 +258,7 @@ class CubeAnimationController: UIPercentDrivenInteractiveTransition, UIViewContr
// set the view's layer to the final value. fixes flickering at the end of the animation
- view.layer.transform = (transformAnimation.toValue as! NSValue).CATransform3DValue
+ view.layer.transform = (transformAnimation.toValue as! NSValue).caTransform3DValue
return transformAnimation
}
diff --git a/CustomTransition Dojo 2/CustomTransition/Transitions/ImageAnimationController.swift b/CustomTransition Dojo 2/CustomTransition/Transitions/ImageAnimationController.swift
index 0f6b882..e1f1551 100644
--- a/CustomTransition Dojo 2/CustomTransition/Transitions/ImageAnimationController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/Transitions/ImageAnimationController.swift
@@ -16,19 +16,19 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
let imageView = UIImageView ()
imageView.image = UIImage(named: "balloons.png")
- imageView.contentMode = UIViewContentMode.ScaleAspectFill
+ imageView.contentMode = UIViewContentMode.scaleAspectFill
return imageView
}()
//MARK: - UIViewControllerAnimatedTransitioning
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 1.0
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
if self.reverseAnimation {
animateOut(transitionContext)
}
@@ -39,16 +39,16 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
//MARK: - Animations
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)! as! TransitionsTableViewController
- let imageViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! as! TransitionsTableViewController
+ let imageViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let detailView = imageViewController.view
- let indexPath = NSIndexPath(forRow: 3, inSection: 0)
- let cell = tableViewController.tableView.cellForRowAtIndexPath(indexPath)
- let rect = cell?.imageView?.convertRect((cell?.imageView?.frame)!, toView: containerView)
+ let indexPath = IndexPath(row: 3, section: 0)
+ let cell = tableViewController.tableView.cellForRow(at: indexPath)
+ let rect = cell?.imageView?.convert((cell?.imageView?.frame)!, to: containerView)
tempImageView.frame = rect!
containerView.addSubview(tempImageView)
@@ -58,9 +58,9 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
// tempImageView.bounds = (imageView?.bounds)!;
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
- UIView.animateWithDuration(duration, delay:0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration, delay:0, options: UIViewAnimationOptions(), animations: { () -> Void in
self.tempImageView.frame = containerView.bounds
@@ -69,8 +69,8 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}) { (animationCompleted: Bool) -> Void in
// since the detail view was just built, it needs to be added to the view heirarchy
- containerView.addSubview(detailView)
- detailView.frame = containerView.bounds
+ containerView.addSubview(detailView!)
+ detailView?.frame = containerView.bounds
self.tempImageView.removeFromSuperview()
// when the animation is done we need to complete the transition
@@ -78,16 +78,16 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)! as! TransitionsTableViewController
- let imageViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! as! TransitionsTableViewController
+ let imageViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let detailView = imageViewController.view
- let indexPath = NSIndexPath(forRow: 3, inSection: 0)
- let cell = tableViewController.tableView.cellForRowAtIndexPath(indexPath)
- let rect = cell?.imageView?.convertRect((cell?.imageView?.frame)!, toView: containerView)
+ let indexPath = IndexPath(row: 3, section: 0)
+ let cell = tableViewController.tableView.cellForRow(at: indexPath)
+ let rect = cell?.imageView?.convert((cell?.imageView?.frame)!, to: containerView)
tempImageView.frame = containerView.bounds
containerView.addSubview(tableViewController.view)
@@ -98,9 +98,9 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
// tempImageView.bounds = (imageView?.bounds)!;
imageViewController.view.alpha = 0
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
- UIView.animateWithDuration(duration, delay:0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration, delay:0, options: UIViewAnimationOptions(), animations: { () -> Void in
self.tempImageView.frame = rect!
@@ -109,7 +109,7 @@ class ImageAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}) { (animationCompleted: Bool) -> Void in
// since the detail view was just built, it needs to be added to the view heirarchy
- containerView.addSubview(detailView)
+ containerView.addSubview(detailView!)
self.tempImageView.removeFromSuperview()
diff --git a/CustomTransition Dojo 2/CustomTransition/Transitions/PopupAnimationController.swift b/CustomTransition Dojo 2/CustomTransition/Transitions/PopupAnimationController.swift
index 90b545b..ef93462 100644
--- a/CustomTransition Dojo 2/CustomTransition/Transitions/PopupAnimationController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/Transitions/PopupAnimationController.swift
@@ -12,19 +12,19 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
var reverseAnimation: Bool = false
lazy var dimmerView: UIView = {
- let view = UIView(frame: CGRectZero)
- view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.8)
+ let view = UIView(frame: CGRect.zero)
+ view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
return view
}()
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 1.25
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -34,19 +34,19 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
}
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let duration = self.transitionDuration(transitionContext)
- let containerView = transitionContext.containerView()
- let popupViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let duration = self.transitionDuration(using: transitionContext)
+ let containerView = transitionContext.containerView
+ let popupViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let popupView = popupViewController.view
let popupSize = popupViewController.preferredContentSize
let scaleValues: [NSValue] = [
- NSValue(CATransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, -500, 0), 0, 0, 1)),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.75, 1), 0, 200, 0)),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(0.8, 1.3, 1), 0, -55, 0)),
- NSValue(CATransform3D: CATransform3DIdentity)
+ NSValue(caTransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, -500, 0), 0, 0, 1)),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.75, 1), 0, 200, 0)),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(0.8, 1.3, 1), 0, -55, 0)),
+ NSValue(caTransform3D: CATransform3DIdentity)
]
let transformAnimation = CAKeyframeAnimation(keyPath: "transform")
@@ -72,36 +72,36 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
dimmerFadeAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
dimmerFadeAnimation.completionBlock = { (finished: Bool) -> Void in
if finished {
- containerView!.addSubview(popupView)
+ containerView.addSubview(popupView!)
// set the layer to its final value before adding the animation
- popupView.layer.transform = CATransform3DIdentity
+ popupView?.layer.transform = CATransform3DIdentity
- popupView.layer.addAnimation(transformAnimation, forKey: "transformAnimation")
+ popupView?.layer.add(transformAnimation, forKey: "transformAnimation")
}
else {
transitionContext.completeTransition(finished)
}
}
- popupView.frame = CGRect(origin: CGPointZero, size: popupSize)
- popupView.center = containerView!.center
+ popupView?.frame = CGRect(origin: CGPoint.zero, size: popupSize)
+ popupView?.center = containerView.center
// display the dimmer
- containerView!.addSubview(self.dimmerView)
- self.dimmerView.frame = containerView!.bounds
+ containerView.addSubview(self.dimmerView)
+ self.dimmerView.frame = containerView.bounds
// set the layer to its final value before adding the animation
self.dimmerView.layer.opacity = 1
- self.dimmerView.layer.addAnimation(dimmerFadeAnimation, forKey: "dimmerFadeAnimation")
+ self.dimmerView.layer.add(dimmerFadeAnimation, forKey: "dimmerFadeAnimation")
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let duration = self.transitionDuration(transitionContext)
- let popupViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let duration = self.transitionDuration(using: transitionContext)
+ let popupViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let popupView = popupViewController.view
let dimmerFadeAnimation = CABasicAnimation(keyPath: "opacity")
@@ -115,9 +115,9 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
}
let scaleValues: [NSValue] = [
- NSValue(CATransform3D: CATransform3DIdentity),
- NSValue(CATransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.9, 1), 0, -100, 0)),
- NSValue(CATransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, 500, 0), 0, 0.5, 1)),
+ NSValue(caTransform3D: CATransform3DIdentity),
+ NSValue(caTransform3D: CATransform3DTranslate(CATransform3DMakeScale(1.2, 0.9, 1), 0, -100, 0)),
+ NSValue(caTransform3D: CATransform3DScale(CATransform3DMakeTranslation(0, 500, 0), 0, 0.5, 1)),
]
let transformAnimation = CAKeyframeAnimation(keyPath: "transform")
@@ -132,7 +132,7 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
transformAnimation.completionBlock = { (finished: Bool) -> Void in
if finished {
self.dimmerView.layer.opacity = 0
- self.dimmerView.layer.addAnimation(dimmerFadeAnimation, forKey: "fadeAnimation")
+ self.dimmerView.layer.add(dimmerFadeAnimation, forKey: "fadeAnimation")
}
else {
transitionContext.completeTransition(finished)
@@ -141,8 +141,8 @@ class PopupAnimationController: NSObject, UIViewControllerAnimatedTransitioning
// its important to set the layer to its final values when adding the animation, without this,
// you can get a flicker showing the original values when the animation ends.
- popupView.layer.transform = scaleValues.last!.CATransform3DValue
- popupView.layer.addAnimation(transformAnimation, forKey: "transformAnimation")
+ popupView?.layer.transform = scaleValues.last!.caTransform3DValue
+ popupView?.layer.add(transformAnimation, forKey: "transformAnimation")
}
}
diff --git a/CustomTransition Dojo 2/CustomTransition/Transitions/ZoomAnimationController.swift b/CustomTransition Dojo 2/CustomTransition/Transitions/ZoomAnimationController.swift
index e8f419c..68f3dbb 100644
--- a/CustomTransition Dojo 2/CustomTransition/Transitions/ZoomAnimationController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/Transitions/ZoomAnimationController.swift
@@ -9,7 +9,7 @@
import UIKit
class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
- private struct Zoom
+ fileprivate struct Zoom
{
static let minimum: CGFloat = 0.1, maximum: CGFloat = 5.0
}
@@ -19,13 +19,13 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
//MARK: -
- func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 0.4
}
- func animateTransition(transitionContext: UIViewControllerContextTransitioning)
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.reverseAnimation {
animateOut(transitionContext)
@@ -37,34 +37,34 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
//MARK: - Animations
- func animateIn(transitionContext: UIViewControllerContextTransitioning)
+ func animateIn(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
- let detailViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
+ let detailViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
- let containerView: UIView = transitionContext.containerView()!
+ let containerView: UIView = transitionContext.containerView
let detailView = detailViewController.view
let tableView = tableViewController.view
- let duration = self.transitionDuration(transitionContext)
+ let duration = self.transitionDuration(using: transitionContext)
// since the detail view was just built, it needs to be added to the view heirarchy
- containerView.addSubview(detailView)
- detailView.frame = containerView.bounds
+ containerView.addSubview(detailView!)
+ detailView?.frame = containerView.bounds
- detailView.alpha = 0
- detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
+ detailView?.alpha = 0
+ detailView?.transform = CGAffineTransform(scaleX: Zoom.maximum, y: Zoom.maximum)
- UIView.animateWithDuration(duration, delay:0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
+ UIView.animate(withDuration: duration, delay:0, options: UIViewAnimationOptions(), animations: { () -> Void in
- detailView.alpha = 1
- detailView.transform = CGAffineTransformIdentity
- tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
+ detailView?.alpha = 1
+ detailView?.transform = CGAffineTransform.identity
+ tableView?.transform = CGAffineTransform(scaleX: Zoom.minimum, y: Zoom.minimum)
}) { (animationCompleted: Bool) -> Void in
// return the table view back to its original state
- tableView.transform = CGAffineTransformIdentity
+ tableView?.transform = CGAffineTransform.identity
// when the animation is done we need to complete the transition
transitionContext.completeTransition(animationCompleted)
@@ -72,30 +72,30 @@ class ZoomAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
}
- func animateOut(transitionContext: UIViewControllerContextTransitioning)
+ func animateOut(_ transitionContext: UIViewControllerContextTransitioning)
{
- let tableViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
- let detailViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
+ let tableViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
+ let detailViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let detailView = detailViewController.view
let tableView = tableViewController.view
- tableView.frame = transitionContext.finalFrameForViewController(tableViewController)
- tableView.alpha = 0
- tableView.transform = CGAffineTransformMakeScale(Zoom.minimum, Zoom.minimum)
+ tableView?.frame = transitionContext.finalFrame(for: tableViewController)
+ tableView?.alpha = 0
+ tableView?.transform = CGAffineTransform(scaleX: Zoom.minimum, y: Zoom.minimum)
- UIView.animateWithDuration(self.transitionDuration(transitionContext), delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
+ UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in
- tableView.alpha = 1
- tableView.transform = CGAffineTransformIdentity
+ tableView?.alpha = 1
+ tableView?.transform = CGAffineTransform.identity
- detailView.alpha = 0
- detailView.transform = CGAffineTransformMakeScale(Zoom.maximum, Zoom.maximum)
+ detailView?.alpha = 0
+ detailView?.transform = CGAffineTransform(scaleX: Zoom.maximum, y: Zoom.maximum)
}) { (animationCompleted: Bool) -> Void in
- detailView.alpha = 1
- detailView.transform = CGAffineTransformIdentity
+ detailView?.alpha = 1
+ detailView?.transform = CGAffineTransform.identity
transitionContext.completeTransition(animationCompleted)
}
diff --git a/CustomTransition Dojo 2/CustomTransition/View Controllers/DetailViewController.swift b/CustomTransition Dojo 2/CustomTransition/View Controllers/DetailViewController.swift
index 7d2787a..8d72fba 100644
--- a/CustomTransition Dojo 2/CustomTransition/View Controllers/DetailViewController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/View Controllers/DetailViewController.swift
@@ -15,14 +15,14 @@ class DetailViewController: UIViewController {
override func viewDidLoad()
{
super.viewDidLoad()
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(DetailViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
}
diff --git a/CustomTransition Dojo 2/CustomTransition/View Controllers/ImageViewController.swift b/CustomTransition Dojo 2/CustomTransition/View Controllers/ImageViewController.swift
index 3e2abb1..d7ae1e7 100644
--- a/CustomTransition Dojo 2/CustomTransition/View Controllers/ImageViewController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/View Controllers/ImageViewController.swift
@@ -18,30 +18,30 @@ class ImageViewController: UIViewController {
textView.alpha = 0.0
// Do any additional setup after loading the view.
- self.imageView.userInteractionEnabled = true
- let tap = UITapGestureRecognizer(target: self, action: "tap")
+ self.imageView.isUserInteractionEnabled = true
+ let tap = UITapGestureRecognizer(target: self, action: #selector(ImageViewController.tap))
self.imageView.addGestureRecognizer(tap)
- self.textView.userInteractionEnabled = false
+ self.textView.isUserInteractionEnabled = false
- self.navigationController?.navigationBarHidden = true
+ self.navigationController?.isNavigationBarHidden = true
}
- func tap ()
+ @objc func tap ()
{
- UIView.animateWithDuration(0.5, animations: { () -> Void in
+ UIView.animate(withDuration: 0.5, animations: { () -> Void in
self.textView.alpha = 0.0
- }) { (bool) -> Void in
- self.navigationController?.popViewControllerAnimated(true)
- }
+ }, completion: { (bool) -> Void in
+ self.navigationController?.popViewController(animated: true)
+ })
}
- override func viewDidAppear(animated: Bool) {
+ override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
- UIView.animateWithDuration(0.5) { () -> Void in
+ UIView.animate(withDuration: 0.5, animations: { () -> Void in
self.textView.alpha = 1.0
- }
+ })
}
override func didReceiveMemoryWarning() {
diff --git a/CustomTransition Dojo 2/CustomTransition/View Controllers/PopupViewController.swift b/CustomTransition Dojo 2/CustomTransition/View Controllers/PopupViewController.swift
index bb2377f..32ddd2c 100644
--- a/CustomTransition Dojo 2/CustomTransition/View Controllers/PopupViewController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/View Controllers/PopupViewController.swift
@@ -17,25 +17,25 @@ class PopupViewController: UIViewController, UIViewControllerTransitioningDelega
self.preferredContentSize = CGSize(width: 200, height: 100)
self.view.clipsToBounds = true
self.view.layer.cornerRadius = 4
- self.view.layer.borderColor = UIColor.darkGrayColor().CGColor
+ self.view.layer.borderColor = UIColor.darkGray.cgColor
self.view.layer.borderWidth = 1
- self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("tapped")))
+ self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(PopupViewController.tapped)))
}
- func tapped() {
- self.dismissViewControllerAnimated(true, completion: nil)
+ @objc func tapped() {
+ self.dismiss(animated: true, completion: nil)
}
- override func preferredStatusBarStyle() -> UIStatusBarStyle {
- return .LightContent
+ override var preferredStatusBarStyle : UIStatusBarStyle {
+ return .lightContent
}
required init?(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
self.transitioningDelegate = self
- self.modalPresentationStyle = .Custom
+ self.modalPresentationStyle = .custom
}
@@ -43,13 +43,13 @@ class PopupViewController: UIViewController, UIViewControllerTransitioningDelega
lazy var popupAnimation = PopupAnimationController()
- func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.popupAnimation.reverseAnimation = false
return self.popupAnimation
}
- func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.popupAnimation.reverseAnimation = true
return self.popupAnimation
diff --git a/CustomTransition Dojo 2/CustomTransition/View Controllers/TransitionsTableViewController.swift b/CustomTransition Dojo 2/CustomTransition/View Controllers/TransitionsTableViewController.swift
index 8a94688..4b9146c 100644
--- a/CustomTransition Dojo 2/CustomTransition/View Controllers/TransitionsTableViewController.swift
+++ b/CustomTransition Dojo 2/CustomTransition/View Controllers/TransitionsTableViewController.swift
@@ -10,20 +10,20 @@ import UIKit
class TransitionsTableViewController: UITableViewController, UIViewControllerTransitioningDelegate, UINavigationControllerDelegate {
- override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch (indexPath.row) {
case 0:
- let zoomVC = self.storyboard!.instantiateViewControllerWithIdentifier("detailViewController")
+ let zoomVC = self.storyboard!.instantiateViewController(withIdentifier: "detailViewController")
zoomVC.transitioningDelegate = self
- zoomVC.modalPresentationStyle = .Custom
- self.presentViewController(zoomVC, animated: true, completion: nil)
+ zoomVC.modalPresentationStyle = .custom
+ self.present(zoomVC, animated: true, completion: nil)
break
case 1:
- let popupVC = self.storyboard!.instantiateViewControllerWithIdentifier("popupViewController")
- self.presentViewController(popupVC, animated: true, completion: nil)
+ let popupVC = self.storyboard!.instantiateViewController(withIdentifier: "popupViewController")
+ self.present(popupVC, animated: true, completion: nil)
break
case 2:
- let cubeVC = self.storyboard!.instantiateViewControllerWithIdentifier("cubeViewController")
+ let cubeVC = self.storyboard!.instantiateViewController(withIdentifier: "cubeViewController")
self.navigationController?.delegate = self
self.navigationController?.pushViewController(cubeVC, animated: true)
break
@@ -31,7 +31,7 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
break
}
- tableView.deselectRowAtIndexPath(indexPath, animated: false);
+ tableView.deselectRow(at: indexPath, animated: false);
}
//MARK: -
@@ -40,9 +40,9 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
lazy var cubeAnimation = CubeAnimationController()
lazy var imageAnimation = ImageAnimationController()
- func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
- if presented.isKindOfClass(DetailViewController) {
+ if presented.isKind(of: DetailViewController.self) {
self.zoomAnimation.reverseAnimation = false
return self.zoomAnimation
}
@@ -50,9 +50,9 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
return nil
}
- func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
- if dismissed.isKindOfClass(DetailViewController) {
+ if dismissed.isKind(of: DetailViewController.self) {
self.zoomAnimation.reverseAnimation = true
return self.zoomAnimation
}
@@ -62,11 +62,11 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
//MARK: - UINavigationControllerDelegate
- func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
+ func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
switch (operation) {
- case .Pop:
+ case .pop:
self.imageAnimation.reverseAnimation = true
break
@@ -78,7 +78,7 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
return self.imageAnimation
}
- func navigationController(navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
+ func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
{
if self.cubeAnimation.interactive {
return self.cubeAnimation
@@ -86,7 +86,7 @@ class TransitionsTableViewController: UITableViewController, UIViewControllerTra
return nil
}
- override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
self.navigationController?.delegate = self
}