I am working on animating my view which contains an ImageView and a Label. Please see figure 1. I am trying to animate upperView when scrolling on below tableView is done. And the final result should look like Figure 2. where the imageView's height and width is reduced and is at the left corner with minimum height and label in front of the imageView. Animation is working fine, the imageView goes from Original position to final position smoothly and so does the Label. But the upperView doesn't works as per the animation.
I tried it with upperViews Height Constraint and by its frame.
If I change it with its height Constraint it goes to its final position very quickly.
And if I give height using upperView.frame.size.height then the view goes up but the table view remains on their places.
Here is what I have tried
func scrollViewDidScroll(scrollView: UIScrollView) {
if scrollView.contentOffset.y > 0
{
UIView.animateWithDuration(1.5, delay: 0.0, options: .CurveEaseOut, animations:
{
self.imageView.frame = CGRect(x: 5.0, y: 0.0, width: 30, height: 40)
}, completion: { finished in
UIView.animateWithDuration(1.5, delay: 1.0, options: UIViewAnimationOptions.AllowUserInteraction,animations: {
self.selectedProgramNameLabel.center = CGPoint(x: self.selectedProgramNameLabel.center.x, y: self.imageView.center.y)
}, completion: { finished in
UIView.animateWithDuration(1.5, delay: 2.0, options: UIViewAnimationOptions.AllowUserInteraction, animations: {
self.upperViewHeightConstraint.constant = 50
}, completion: { finished in
})
})
})
}
else if scrollView.contentOffset.y == 0
{
UIView.animateWithDuration(1.5, delay: 0.0, options: .CurveEaseOut, animations:
{
self.selectedProgramNameLabel.center = CGPoint(x: self.selectedProgramNameLabel.center.x, y: self.imageView.center.y + self.imageView.frame.height - 45)
}, completion: { finished in
UIView.animateWithDuration(1.5, delay: 0.0, options: UIViewAnimationOptions.AllowUserInteraction,animations: {
self.imageView.frame = CGRect(x: self.upperView.frame.origin.x, y: self.upperView.frame.origin.y, width: 100.0, height: 134)
}, completion: { finished in
UIView.animateWithDuration(1.5, delay: 1.0, options: UIViewAnimationOptions.AllowUserInteraction, animations: {
}, completion: { finished in
})
})
})
}
TIA.