无法将“CGFloat”类型的值转换为预期的参数类型“Double”

时间:2016-07-20 10:02:21

标签: ios swift double cgfloat

我试图根据UIPanGestureRecognizer的速度移动一个UIView,为此我编写了这段代码,我在这一行得到了错误

var duration:NSTimeInterval = yPoints / velocity

这是代码的一部分

let velocity = pan.velocityInView(self.superview).y
var yPoints: CGFloat = 100.0
            var duration: NSTimeInterval = yPoints / velocity
            var offScreenCenter: CGFloat = self.superview!.frame.origin.y
            offScreenCenter += yPoints
            UIView.animateWithDuration(duration, animations: {() -> Void in
                self.superview!.frame.origin.y = offScreenCenter
            })

我可以将此转换为Double吗?或者需要更改代码?

0 个答案:

没有答案
相关问题