0

I want to animate the label from bottom to top when opening a view controller.

Can I Animated the label Without frameworks or pod file?

ymutlu
  • 6,585
  • 4
  • 35
  • 47
Vignesh J
  • 257
  • 1
  • 2
  • 14

2 Answers2

9

There's no need to use frameworks or pods for what you are trying to accomplish. You can simply use the following method and tweak the duration and distance to fit your needs.

    UIView.animate(withDuration: 2, delay: 0, options: [.curveEaseOut], 
    animations: {
        label.center.y -= self.view.bounds.height - 100
        self.view.layoutIfNeeded()
    }, completion: nil)

The "-100" is there so that you don't animate the label out of the view completely. If your label starts closer to the top you will need to increase this number and vice versa

Zach Fuller
  • 1,219
  • 2
  • 14
  • 18
1

Here transition example with Swift 1.2, from another question.

Swift 3, 4, 5

UIView.transition(with: status, duration: 0.33, options:
    [.curveEaseOut, .transitionCurlDown], animations: {
        //...animations
}, completion: {_ in
    //....transition completion
    delay(seconds: 2.0) {

    }
})

Swift 2.0

UIView.transitionWithView(status, duration: 0.33, options:
        [.CurveEaseOut, .TransitionCurlDown], animations: {
            //...animations
     }, completion: {_ in
            //....transition completion
            delay(seconds: 2.0) {

     }
})

Swift 1.2

UIView.transitionWithView(status, duration: 0.33, options:
        .CurveEaseOut | .TransitionCurlDown, animations: {
            //...animations
     }, completion: {_ in
            //transition completion
            delay(seconds: 2.0) {

     }
})
Karen Hovhannisyan
  • 1,140
  • 2
  • 21
  • 31
ymutlu
  • 6,585
  • 4
  • 35
  • 47