Convert NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey] to Enum

Using NSNumber from NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey]

In Objective-C, I would do the following

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

Swift won't let me do the same, although the bit-break statement is the same. I would like to get an enum raw value that is equivalent

UIViewAnimationOptionCurveEaseInOut = 0 <16,

UIViewAnimationOptionCurveEaseIn = 1 <16,

UIViewAnimationOptionCurveEaseOut = 2 <16,

UIViewAnimationOptionCurveLinear = 3 <16,

Update


I'm not sure if the approach below fits, it seems to work

  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) 
+7
ios swift
source share
4 answers

In Beta-5

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

You should initialize UIViewAnimationOptions with rawValue as follows:

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

+1
source share

That's what you need?

 UIViewAnimationCurve.fromRaw(Int(hereGoesYourStuff)) 
0
source share
 let animationKey = userInfo[UIKeyboardAnimationCurveUserInfoKey] as UInt UIViewAnimationOptions(rawValue: animationKey) 
-one
source share

All Articles