I am trying to implement this cool feature where the logo after the app loads moves up slightly and the login view appears. The problem is that when I use this code:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
UIView.animateWithDuration(2, animations: {
var newCenter = self.logoImage.center
newCenter.y -= 100
self.logoImage.center = newCenter
}, completion: { finished in
println("Basket doors opened!")
})
}
The logo is moved to the origin place from the place I want it to move to. So in this example logo appears already with (y-100) and then moves to the origin X,Y.
Since the view isn't actually laid out / on the screen in viewDidLoad()
you shouldn't be trying to animate anything there. Instead, you should wait until the view is completely presented, which happens in viewDidAppear(animated: Bool)
. Also, I would recommend calculating the newCenter
var outside of the animation call, then simply setting self.logoImage.center = newCenter
within the animation call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With