Last active
May 29, 2018 09:56
-
-
Save SwCake1/be73e06038fac4d768bb0bbb2ac0f9b9 to your computer and use it in GitHub Desktop.
ASDK animation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func animateLayoutTransition(_ context: ASContextTransitioning) { | |
if textNode.text == "" { | |
let finalTextFrame = context.finalFrame(for: textNode) | |
var finalButtonFrame = context.initialFrame(for: cancelButton) | |
finalButtonFrame.origin.x = UIScreen.main.bounds.width | |
UIView.animate(withDuration: 0.1, animations: { | |
self.textNode.frame = finalTextFrame | |
self.cancelButton.frame = finalButtonFrame | |
}, completion: { finished in | |
context.completeTransition(finished) | |
}) | |
} else { | |
let finalTextFrame = context.finalFrame(for: textNode) | |
let finalButtonFrame = context.finalFrame(for: cancelButton) | |
cancelButton.frame = finalButtonFrame | |
let initialButtonFrame = context.initialFrame(for: cancelButton) | |
if initialButtonFrame.isEmpty { | |
cancelButton.frame.origin.x = UIScreen.main.bounds.width | |
} | |
UIView.animate(withDuration: 0.1, animations: { | |
self.textNode.frame = finalTextFrame | |
self.cancelButton.frame = finalButtonFrame | |
}, completion: { finished in | |
context.completeTransition(finished) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment