From fc52617d42591f7c712ccf068cbd77a43596a711 Mon Sep 17 00:00:00 2001 From: nghialv Date: Sun, 24 May 2015 16:00:46 +0900 Subject: [PATCH] refactoring --- Source/MKButton.swift | 11 ++++------- Source/MKTextField.swift | 11 ++++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/MKButton.swift b/Source/MKButton.swift index 0791db3..8a61d53 100644 --- a/Source/MKButton.swift +++ b/Source/MKButton.swift @@ -42,9 +42,10 @@ public class MKButton : UIButton } @IBInspectable public var rippleAniDuration: Float = 0.75 @IBInspectable public var backgroundAniDuration: Float = 1.0 + @IBInspectable public var shadowAniDuration: Float = 0.65 + @IBInspectable public var rippleAniTimingFunction: MKTimingFunction = .Linear @IBInspectable public var backgroundAniTimingFunction: MKTimingFunction = .Linear - @IBInspectable public var shadowAniDuration: Float = 0.65 @IBInspectable public var shadowAniTimingFunction: MKTimingFunction = .EaseOut @IBInspectable public var cornerRadius: CGFloat = 2.5 { @@ -109,12 +110,8 @@ public class MKButton : UIButton if shadowAniEnabled { let shadowRadius = layer.shadowRadius let shadowOpacity = layer.shadowOpacity - - //if mkType == .Flat { - // mkLayer.animateMaskLayerShadow() - //} else { - mkLayer.animateSuperLayerShadow(10, toRadius: shadowRadius, fromOpacity: 0, toOpacity: shadowOpacity, timingFunction: shadowAniTimingFunction, duration: CFTimeInterval(shadowAniDuration)) - //} + let duration = CFTimeInterval(shadowAniDuration) + mkLayer.animateSuperLayerShadow(10, toRadius: shadowRadius, fromOpacity: 0, toOpacity: shadowOpacity, timingFunction: shadowAniTimingFunction, duration: duration) } return super.beginTrackingWithTouch(touch, withEvent: event) diff --git a/Source/MKTextField.swift b/Source/MKTextField.swift index e8b93cf..ca52a0f 100644 --- a/Source/MKTextField.swift +++ b/Source/MKTextField.swift @@ -23,8 +23,9 @@ public class MKTextField : UITextField { @IBInspectable public var rippleAniDuration: Float = 0.75 @IBInspectable public var backgroundAniDuration: Float = 1.0 - @IBInspectable public var rippleAniTimingFunction: MKTimingFunction = .Linear @IBInspectable public var shadowAniEnabled: Bool = true + @IBInspectable public var rippleAniTimingFunction: MKTimingFunction = .Linear + @IBInspectable public var cornerRadius: CGFloat = 2.5 { didSet { layer.cornerRadius = cornerRadius @@ -42,7 +43,6 @@ public class MKTextField : UITextField { mkLayer.setBackgroundLayerColor(backgroundLayerColor) } } - // floating label @IBInspectable public var floatingLabelFont: UIFont = UIFont.boldSystemFontOfSize(10.0) { @@ -185,9 +185,10 @@ private extension MKTextField { private func showFloatingLabel() { let curFrame = floatingLabel.frame floatingLabel.frame = CGRect(x: curFrame.origin.x, y: bounds.height/2, width: curFrame.width, height: curFrame.height) - UIView.animateWithDuration(0.45, delay: 0.0, options: .CurveEaseOut, animations: { - self.floatingLabel.alpha = 1.0 - self.floatingLabel.frame = curFrame + UIView.animateWithDuration(0.45, delay: 0.0, options: .CurveEaseOut, + animations: { + self.floatingLabel.alpha = 1.0 + self.floatingLabel.frame = curFrame }, completion: nil) }