将NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey]转换为Enum

从NSNotification.userInfo使用NSNumber [UIKeyboardAnimationCurveUserInfoKey]

在Objective Objective中,将执行以下操作

 [UIView animateWithDuration:1.0
                      delay:0
                    options:(curveValue.intValue << 16)

即使移位运算符相同,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)

在Beta-5中

UIViewAnimationOptions.fromRaw(
    UInt(
        ( p.userInfo[ UIKeyboardAnimationCurveUserInfoKey ] as NSNumber ).unsignedIntValue << 16
    )
)!

您必须像这样使用rawValue初始化UIViewAnimationOptions:

UIView.animateWithDuration(1.0, delay: 0, options: UIViewAnimationOptions.init(rawValue:UInt(curveValue.intValue << 16)),


这是你需要的吗?

UIViewAnimationCurve.fromRaw(Int(hereGoesYourStuff))
链接地址: http://www.djcxy.com/p/20749.html

上一篇: Convert NSNotification.userInfo[UIKeyboardAnimationCurveUserInfoKey] to Enum

下一篇: C Programming Language Example About Arrays