将NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey]转换为Enum

Rya*_*ner 9 ios swift

使用NSNotification.userInfo中的NSNumber [UIKeyboardAnimationCurveUserInfoKey]

目标CI将执行以下操作

 [UIView animateWithDuration:1.0
                      delay:0
                    options:(curveValue.intValue << 16)
Run Code Online (Sandbox Code Playgroud)

即使bitshift运算符相同,Swift也不允许我这样做.我想获得相当于枚举的原始值

UIViewAnimationOptionCurveEaseInOut = 0 << 16,

UIViewAnimationOptionCurveEaseIn = 1 << 16,

UIViewAnimationOptionCurveEaseOut = 2 << 16,

UIViewAnimationOptionCurveLinear = 3 << 16,

更新


我不确定以下方法是否正确,似乎有效

 var animationCurve : UIViewAnimationOptions = UIViewAnimationOptions.CurveEaseOut
 info[UIKeyboardAnimationCurveUserInfoKey].getValue(&animationCurve)


 UIView.animateWithDuration(durationValue.doubleValue,
        delay: 0,
        options: animationCurve,
        animations: {self.navigationController.toolbar.frame = myRect},
        completion: nil)
Run Code Online (Sandbox Code Playgroud)

Fer*_*zon -1

这是你需要的吗?

UIViewAnimationCurve.fromRaw(Int(hereGoesYourStuff))
Run Code Online (Sandbox Code Playgroud)

  • 由于 UIKeyboardAnimationCurveUserInfoKey 的值为 7,且 SDK 中未记录,因此 UIViewAnimationCurve.fromRaw(7) 将返回 nil (8认同)