I am trying to get the UIAnimationCurve of the keyboard, if it exists. The code I am using is below:
if let kbCurve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int{
animateCurve = UIViewAnimationCurve.
}
However, animateCurve, being a UIViewAnimationCurve, cannot be converted from an Int. How do I get the curve this way?
If I treat them as numbers, not UIViewAnimationCurve enums, the below errors when attempting to animate:
//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()
}
)
Is there a way to set the curve using an int?
Attempted int curve with:
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()
}
)
But compile error occurs due to UIViewAnimationOptions not being correct type. If I run the assignment of UIViewAnimationOptions on it's own, I get the compiler error "Could not find an overload for 'init' that accepts the supplied arguments."
as? UIViewAnimationCurve
instead? – Rush