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

前端之家收集整理的这篇文章主要介绍了ios – 将NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey]转换为Enum前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用NSNotification.userInfo中的NSNumber [UIKeyboardAnimationCurveUserInfoKey]

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

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

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

UIViewAnimationOptionCurveEaseInOut = 0<< 16,UIViewAnimationOptionCurveEaseIn = 1<< 16,UIViewAnimationOptionCurveEaSEOut = 2<< 16,UIViewAnimationOptionCurveLinear = 3<< 16,更新 我不确定以下方法是否正确,似乎有效

  1. var animationCurve : UIViewAnimationOptions = UIViewAnimationOptions.CurveEaSEOut
  2. info[UIKeyboardAnimationCurveUserInfoKey].getValue(&animationCurve)
  3.  
  4.  
  5. UIView.animateWithDuration(durationValue.doubleValue,delay: 0,options: animationCurve,animations: {self.navigationController.toolbar.frame = myRect},completion: nil)

解决方法

在Beta-5中
  1. UIViewAnimationOptions.fromRaw(
  2. UInt(
  3. ( p.userInfo[ UIKeyboardAnimationCurveUserInfoKey ] as NSNumber ).unsignedIntValue << 16
  4. )
  5. )!

猜你在找的iOS相关文章