From f54a7e79644b539f2cb35b61ae8c82ec617724da Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 15 Aug 2016 15:24:37 +0800 Subject: [PATCH] refactor UIInterpolatingMotionEffectType.yep_centerKeyPath --- Yep/Extensions/UIMotionEffect+Yep.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Yep/Extensions/UIMotionEffect+Yep.swift b/Yep/Extensions/UIMotionEffect+Yep.swift index 0f41f7840..d0e5ef0ae 100644 --- a/Yep/Extensions/UIMotionEffect+Yep.swift +++ b/Yep/Extensions/UIMotionEffect+Yep.swift @@ -8,12 +8,24 @@ import UIKit +extension UIInterpolatingMotionEffectType { + + var yep_centerKeyPath: String { + switch self { + case .TiltAlongHorizontalAxis: + return "center.x" + case .TiltAlongVerticalAxis: + return "center.y" + } + } +} + extension UIMotionEffect { class func twoAxesShift(strength: Float) -> UIMotionEffect { func motion(type: UIInterpolatingMotionEffectType) -> UIInterpolatingMotionEffect { - let keyPath = type == .TiltAlongHorizontalAxis ? "center.x" : "center.y" + let keyPath = type.yep_centerKeyPath let motion = UIInterpolatingMotionEffect(keyPath: keyPath, type: type) motion.minimumRelativeValue = -strength motion.maximumRelativeValue = strength