Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nghialv committed May 24, 2015
1 parent 64cc6f6 commit fc52617
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 4 additions & 7 deletions Source/MKButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions Source/MKTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +43,6 @@ public class MKTextField : UITextField {
mkLayer.setBackgroundLayerColor(backgroundLayerColor)
}
}


// floating label
@IBInspectable public var floatingLabelFont: UIFont = UIFont.boldSystemFontOfSize(10.0) {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit fc52617

Please sign in to comment.