0

I have an animation thats running fine in iOS 8.1 but in iOS 7.1 the button just appears where it is supposed to be without animation.

The button has leading, trailing and bottom constraints of 0, and height constraint of 80. The constraints are setup in the storyboard.

In the viewWillAppear method I change the bottom constraint to -80 so it isn't seen in the beginning.

When the user presses a button, the button should animate up, I run this method:

func animateCtaUp() { self.ctaView.layoutIfNeeded() UIView.animateWithDuration(0.5, delay: 0, options: .CurveEaseOut, animations: { self.ctaViewBottomConstraint.constant = 0 self.ctaView.layoutIfNeeded() }, completion: { finished in }) } 
4
  • 2
    What does "not working" mean? Does nothing happen? Commented Jan 12, 2015 at 17:33
  • The button just appears where it is supposed to be without animation Commented Jan 12, 2015 at 17:49
  • That code works fine for me when I put a button in the controller's self.view. What is ctaView? Is it the button's superview? Commented Jan 12, 2015 at 22:14
  • Yes, it is. Hmm. Do you have an idea why it is not working in iOS 7.1? Commented Jan 13, 2015 at 8:57

1 Answer 1

0

Basically there were 2 bugs.

The first one was: I had a view without layout constraints. When I added them one of the animations started running.

The second bug was: I was calling

self.ctaView.layoutIfNeeded() 

Instead I should be calling

self.view.layoutIfNeeded 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.