Skip to content

Instantly share code, notes, and snippets.

@saoudrizwan
Last active January 6, 2017 06:26
Show Gist options
  • Save saoudrizwan/7f51936ff7e71fd95b9ef3745efda4e6 to your computer and use it in GitHub Desktop.
Save saoudrizwan/7f51936ff7e71fd95b9ef3745efda4e6 to your computer and use it in GitHub Desktop.
// Add a completion block to the UIViewPropertyAnimator
linesConvergingAnimation.addCompletion({ (position) in
// since this is the reversed animation's completion block, the
// "final position" is the initial animation's target-start-position.
if position == .start {
self.linesAreX = false
// reset constraints back to normal
self.firstLine.snp.remakeConstraints({ (make) in
make.height.equalTo(self.lineHeight)
make.width.equalTo(self.containerView.snp.width)
make.centerX.equalTo(self.containerView.snp.centerX)
make.centerY.equalTo(0 + self.lineHeight/2)
})
self.thirdLine.snp.remakeConstraints({ (make) in
make.height.equalTo(self.lineHeight)
make.width.equalTo(self.containerView.snp.width)
make.centerX.equalTo(self.containerView.snp.centerX)
make.centerY.equalTo(self.containerHeight - self.lineHeight/2)
})
// notice I'm not calling .layoutIfNeeded() because there's nothing new to draw
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment