Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS: How to convert UIViewAnimationCurve to UIViewAnimationOptions?
    primarykey
    data
    text
    <p>The <code>UIKeyboardAnimationCurveUserInfoKey</code> has a <code>UIViewAnimationCurve</code> value. How do I convert it to the corresponding <code>UIViewAnimationOptions</code> value for use with the <code>options</code> argument of <code>+[UIView animateWithDuration:delay:options:animations:completion:]</code>?</p> <pre><code>// UIView.h typedef enum { UIViewAnimationCurveEaseInOut, // slow at beginning and end UIViewAnimationCurveEaseIn, // slow at beginning UIViewAnimationCurveEaseOut, // slow at end UIViewAnimationCurveLinear } UIViewAnimationCurve; // ... enum { // ... UIViewAnimationOptionCurveEaseInOut = 0 &lt;&lt; 16, // default UIViewAnimationOptionCurveEaseIn = 1 &lt;&lt; 16, UIViewAnimationOptionCurveEaseOut = 2 &lt;&lt; 16, UIViewAnimationOptionCurveLinear = 3 &lt;&lt; 16, // ... }; typedef NSUInteger UIViewAnimationOptions; </code></pre> <p>Obviously, I could create a simple category method with a <code>switch</code> statement, like so:</p> <pre><code>// UIView+AnimationOptionsWithCurve.h @interface UIView (AnimationOptionsWithCurve) @end // UIView+AnimationOptionsWithCurve.m @implementation UIView (AnimationOptionsWithCurve) + (UIViewAnimationOptions)animationOptionsWithCurve:(UIViewAnimationCurve)curve { switch (curve) { case UIViewAnimationCurveEaseInOut: return UIViewAnimationOptionCurveEaseInOut; case UIViewAnimationCurveEaseIn: return UIViewAnimationOptionCurveEaseIn; case UIViewAnimationCurveEaseOut: return UIViewAnimationOptionCurveEaseOut; case UIViewAnimationCurveLinear: return UIViewAnimationOptionCurveLinear; } } @end </code></pre> <p>But, is there an even easier/better way?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload