在iOS 8上运行的简单动画,但不适用于iOS 7

时间:2014-11-16 15:30:18

标签: ios ios7 swift uianimation

我在下面有一个简单的动画代码。它应该将UILabel从其当前位置下方的250点移动到其当前位置。它在iOS 8.1的模拟器中运行良好但是当我尝试在iOS 7.1的模拟器中测试它时,动画不是从-250开始,而是从当前位置开始并向上移动。有什么想法吗?

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 个答案:

答案 0 :(得分:0)

检查一下,

//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

    })