简体   繁体   English

在iOS 8上可运行的简单动画,在iOS 7上不可用

[英]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. 应该将UILabel从其当前位置下方的250点移动到其当前位置。 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. 它可以在iOS 8.1的模拟器上正常运行,但是当我尝试在模拟器的iOS 7.1上对其进行测试时,动画不是从-250开始,而是从当前位置开始并向上移动。 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

    })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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