Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cobalamin/43f70220e285075d5c66 to your computer and use it in GitHub Desktop.
Save cobalamin/43f70220e285075d5c66 to your computer and use it in GitHub Desktop.
Using all UIViewAnimationOptions as UIViewKeyframeAnimationOptions
// This enables using all available UIViewAnimationOptions enum values as UIViewAnimationOptions in a Swifty way,
// by brute-force bridging all values with an explicit extension to UIViewKeyframeAnimationOptions.
//
// Thus, code like
//
// let o1 : UIViewKeyframeAnimationOptions = .CalculationModeLinear
// let o2 : UIViewAnimationOptions = .CurveLinear
// let os : UIViewKeyframeAnimationOptions = [o1, UIViewKeyframeAnimationOptions(o2.rawValue)]
//
// becomes:
//
// let os : UIViewKeyframeAnimationOptions = [.CalculationModeLinear, .CurveLinear]
extension UIViewKeyframeAnimationOptions {
static var LayoutSubviews: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.LayoutSubviews.rawValue) } }
static var AllowUserInteraction: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.AllowUserInteraction.rawValue) } }
static var BeginFromCurrentState: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.BeginFromCurrentState.rawValue) } }
static var Repeat: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.Repeat.rawValue) } }
static var Autoreverse: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.Autoreverse.rawValue) } }
static var OverrideInheritedDuration: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.OverrideInheritedDuration.rawValue) } }
static var OverrideInheritedCurve: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.OverrideInheritedCurve.rawValue) } }
static var AllowAnimatedContent: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.AllowAnimatedContent.rawValue) } }
static var ShowHideTransitionViews: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.ShowHideTransitionViews.rawValue) } }
static var OverrideInheritedOptions: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.OverrideInheritedOptions.rawValue) } }
static var CurveEaseInOut: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.CurveEaseInOut.rawValue) } }
static var CurveEaseIn: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.CurveEaseIn.rawValue) } }
static var CurveEaseOut: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.CurveEaseOut.rawValue) } }
static var CurveLinear: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.CurveLinear.rawValue) } }
static var TransitionNone: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionNone.rawValue) } }
static var TransitionFlipFromLeft: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionFlipFromLeft.rawValue) } }
static var TransitionFlipFromRight: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionFlipFromRight.rawValue) } }
static var TransitionCurlUp: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionCurlUp.rawValue) } }
static var TransitionCurlDown: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionCurlDown.rawValue) } }
static var TransitionCrossDissolve: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionCrossDissolve.rawValue) } }
static var TransitionFlipFromTop: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionFlipFromTop.rawValue) } }
static var TransitionFlipFromBottom: UIViewKeyframeAnimationOptions { get { return UIViewKeyframeAnimationOptions(rawValue: UIViewAnimationOptions.TransitionFlipFromBottom.rawValue) } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment