From 1b5fbf3d3ddc977195a849ca6550adfdaf074c18 Mon Sep 17 00:00:00 2001 From: Alexandre Alcuvilla Date: Fri, 7 Sep 2018 00:53:57 +0200 Subject: [PATCH] Select preset and curve animation with enum value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setup the animation was not easy using string, it will be simple to set them up using the enum value. - An Extension.swift file is created. - The extension on Springable object conforms to UIView so this function can also be use on UIButton, UILabel, … func animation(preset: Spring.AnimationPreset, curve: Spring.AnimationCurve) This function help you select your preset and curve using enums. --- Spring/Extensions.swift | 18 ++++++++++++++++++ Spring/Extensions.swift alias | Bin 0 -> 1036 bytes 2 files changed, 18 insertions(+) create mode 100644 Spring/Extensions.swift create mode 100644 Spring/Extensions.swift alias diff --git a/Spring/Extensions.swift b/Spring/Extensions.swift new file mode 100644 index 0000000..fc02df2 --- /dev/null +++ b/Spring/Extensions.swift @@ -0,0 +1,18 @@ + +import UIKit + +// Extension on Springable protocol that conforms to UIView (UIButton, UILabel, ...) +extension Springable where Self: UIView { + + /** + Setup your animation preset and curve. + - Parameters: + - preset: The animation you want to play (`.ZoomIn`, `.ZoomOut`, `.FadeIn`, ...). + - curve: The curve you want to apply to your animation (`.EaseIn`, `.EaseOut`, ...). + - Important: This function only setup preset and curve animation you have to animate it using `yourUIView.animate()` for exemple. + */ + func animation(preset: Spring.AnimationPreset, curve: Spring.AnimationCurve) { + self.animation = preset.rawValue + self.curve = curve.rawValue + } +} diff --git a/Spring/Extensions.swift alias b/Spring/Extensions.swift alias new file mode 100644 index 0000000000000000000000000000000000000000..de6ded02886eaf42900c6e78e89ee15a2c9a9b83 GIT binary patch literal 1036 zcmZ9K&1w@-6vywRA1Vk=+eJSVI*1#=bTZT?X(?zjsaUiwY~xOFlHBOfWTwoFG=hr? zE_?tVAUnJ0qAwuK!o5ZE01D#Pf(S08@qcd5O^651oZtDl=iYnf*1~XCK-ylUY!OV_ z8>8sBN#7{8z530`&0pQLME+jn2S*uX!DCbhn1C@1A*!*A;`5O5y_W1;;9Nz1_*;kSii7&kXJza-tpD<#|Fl1vpSN9Aug}!Q+GA)6J%N6Oow! zJk4^;tNTF`#xJb<6}=v*KUeV?obTh`r9=2Pc+KjDlXsn!Vz%HG%GqUj*|L*&vZX@4 z?B*PIwU~GGUEa_d=+Bu^OEKEthFxHOv|WAtuoBi^wq=lPHt_MAzKkBoSHru!!=+cK z9