简体   繁体   中英

Simple animation working on iOS 8 but not iOS 7

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()
    })

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

    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM