0

I'm doing an incredibly simple animation. I'm just moving a button down.

    UIView.animateWithDuration(1.0) { () -> Void in
        self.backButton.center.y += 30.0
    }

From my understanding, and what I've read of other answers to similar questions this should be all it takes.

But what instead happens, the button teleports (for lack of a better word) up 30 and then animates back to the original position. I've been tearing out my hair at this little problem. Any help is appreciated!

Kavsub
  • 11
  • 2
  • On iOS, the coordinate system is such that positive y is down on the screen. So if the up you are referring to is up on the screen, then the center's y value must have decreased in value. Did you subtract from center.y prior to the animation? – SwiftMatt Jan 03 '16 at 03:46
  • @ConspicuousGuy, when I added print statements it didn't indicate anything like that was happening. – Kavsub Jan 03 '16 at 03:52
  • So the self.backButton.center.y += 30.0 is the only time self.backButton.center.y or anything relating to the y position of the backButton is altered? – SwiftMatt Jan 03 '16 at 03:53
  • @SwiftMatt, in the viewDidLoad method I added constraints to the button. That would be the only time it's position is altered. – Kavsub Jan 03 '16 at 03:59
  • Well it sounds like the animation is going down as you want it to, but something is moving the button UP before the animation. – SwiftMatt Jan 03 '16 at 04:01

1 Answers1

1

So after banging my head against a wall for a bit, I realized that layout constraints were causing the issue. I was looking at outdated questions.

Here's the workaround: iOS: How does one animate to new autolayout constraint (height)

Community
  • 1
  • 1
Kavsub
  • 11
  • 2