Simple animation working on iOS 8 but not iOS 7

118 views Asked by At

I have a simple animation code below. It is supposed to move a UILabel from 250point below of its current location to its current location. It works fine in simulator on iOS 8.1 but when I try to test it on iOS 7.1 in simulator, the animation does not start from -250 , instead it starts from current location and moves upward. Any ideas why?

UIView.animateWithDuration(0.4, delay: 0, options: .CurveEaseOut, animations:{
    var animateLabel = self.signLabel.frame
    animateLabel.origin.y -= 250
    self.signLabel.frame = animateLabel
    }, completion: {finsihed in
    self.doAfterAnimation()
    })
1

There are 1 answers

0
Zaid Pathan On

Check this out,

//To go from Y = -250 to Y = 250

var animateLabel = UILabel(frame: CGRectMake(0, -250, 100, 100))
animateLabel.text = "MyLabel"

    self.view.addSubview(animateLabel)

    UIView.animateWithDuration(5.0, animations: {

        animateLabel.frame.origin.y = 250

    })



 //To go from Y = 250 to Y = -250

var animateLabel = UILabel(frame: CGRectMake(0, 250, 100, 100))
animateLabel.text = "MyLabel"

    self.view.addSubview(animateLabel)

    UIView.animateWithDuration(5.0, animations: {

        animateLabel.frame.origin.y = -250

    })