我正在尝试获取键盘的 UIAnimationCurve(如果存在)。我正在使用的代码如下:
if let kbCurve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int{
animateCurve = UIViewAnimationCurve.
}
但是,作为 UIViewAnimationCurve 的 animateCurve 不能从 Int 转换。我如何以这种方式获得曲线?
如果我将它们视为数字,而不是 UIViewAnimationCurve 枚举,则尝试制作动画时会出现以下错误:
//Animated done button with keyboard
origDoneFrame = btnDone.frame
btnDone.hidden = false
UIView.animateWithDuration(
animateDuration,
delay: Numbers.ANIMATE_DELAY,
options: nil,
animations: {
UIView.setAnimationCurve(animateCurve)
self.btnDone.frame = CGRectMake(self.btnDone.frame.origin.x + kbHeight, self.btnDone.frame.origin.y, self.btnDone.frame.size.width, self.btnDone.frame.size.height)
return Void()
},
completion: {finished in
return Void()
}
)
有没有办法使用int设置曲线?
尝试使用 int 曲线:
UIView.animateWithDuration(
animateDuration,
delay: Numbers.ANIMATE_DELAY,
options: UIViewAnimationOptions(animateCurve << 16),
animations: {
self.btnDone.frame = CGRectMake(self.btnDone.frame.origin.x + kbHeight, self.btnDone.frame.origin.y, self.btnDone.frame.size.width, self.btnDone.frame.size.height)
return Void()
},
completion: {finished in
return Void()
}
)
但是由于 UIViewAnimationOptions 不是正确的类型而发生编译错误。如果我自己运行 UIViewAnimationOptions 的分配,我会收到编译器错误“找不到接受提供的参数的 'init' 的重载”。