微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – 将NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey]转换为Enum

使用NSNotification.userInfo中的NSNumber [UIKeyboardAnimationCurveUserInfoKey]

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

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

即使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)

解决方法

在Beta-5中
UIViewAnimationoptions.fromraw(
    UInt(
        ( p.userInfo[ UIKeyboardAnimationCurveUserInfoKey ] as NSNumber ).unsignedIntValue << 16
    )
)!

原文地址:https://www.jb51.cc/iOS/334229.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐