Skip to content

Commit

Permalink
refactor UIInterpolatingMotionEffectType.yep_centerKeyPath
Browse files Browse the repository at this point in the history
  • Loading branch information
nixzhu committed Aug 15, 2016
1 parent 5017cef commit f54a7e7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Yep/Extensions/UIMotionEffect+Yep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f54a7e7

Please sign in to comment.