Skip to content

Instantly share code, notes, and snippets.

@stefanagapie
Last active August 29, 2015 14:12
Auto Layout and UIScrollView Tutorial
// -- animate the placements of our auto layout constraints -- //
// Place the scroll view slightly offset from center before animating //
self.view.layoutIfNeeded()
self.asvScrollView.center = CGPointMake(CGRectGetMidX(self.view.frame), CGRectGetHeight(self.view.frame)/8.0)
UIView.animateWithDuration(1.75, animations: { () -> Void in
// apply custom constraints to our scroll view //
self.asvApplyHeightAndWidthConstraints()
self.asvApplyCenteringConstraints()
self.view.layoutIfNeeded()
}) { (animated) -> Void in
// -- animation completion block -- //
// Once the initial animation is complete we animate the //
// contents of the scroll view by changing its content offset. //
self.asvScrollView.setContentOffset(CGPointMake(CGRectGetMaxX(self.asvLeftView.frame), 0), animated: true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment