Utilisation de NSNumber à partir de NSNotification.userInfo [UIKeyboardAnimationCurveUserInfoKey]
En Objective CI ferait ce qui suit
[UIView animateWithDuration:1.0 delay:0 options:(curveValue.intValue << 16)
Swift ne me permettra pas de faire la même chose même si l'opérateur bitshift est le même. Je voudrais get la valeur brute enum qui est équivalente
UIViewAnimationOptionCurveEaseInOut = 0 << 16,
UIViewAnimationOptionCurveEaseIn = 1 << 16,
UIViewAnimationOptionCurveEaseOut = 2 << 16,
UIViewAnimationOptionCurveLinear = 3 << 16,
mettre à jour
Je ne suis pas sûr si l'approche ci-dessous est correcte, il semble fonctionner
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)
En bêta-5
UIViewAnimationOptions.fromRaw( UInt( ( p.userInfo[ UIKeyboardAnimationCurveUserInfoKey ] as NSNumber ).unsignedIntValue << 16 ) )!
Vous devez initier un UIViewAnimationOptions avec le rawValue comme ceci:
UIView.animateWithDuration(1.0, delay: 0, options: UIViewAnimationOptions.init(rawValue:UInt(curveValue.intValue << 16)),
Est-ce ce dont vous avez besoin?
UIViewAnimationCurve.fromRaw(Int(hereGoesYourStuff))
let animationKey = userInfo[UIKeyboardAnimationCurveUserInfoKey] as UInt UIViewAnimationOptions(rawValue: animationKey)