Commit ae77e281 by Daniel Dahan

issue-17: minor updates

parent 62f91d73
......@@ -18,47 +18,14 @@
import UIKit
public class FlatButton : MaterialButton {
/**
:name: pulseTitleColor
*/
public var pulseTitleColor: UIColor?
/**
:name: titleColor
*/
public var titleColor: UIColor? {
didSet {
setTitleColor(titleColor, forState: .Normal)
}
}
public class FlatButton : RaisedButton {
//
// :name: prepareButton
//
internal override func prepareButton() {
super.prepareButton()
backgroundColor = .clearColor()
pulseColor = .whiteColor()
backgroundColorView.layer.cornerRadius = 3
}
//
// :name: pulseTouches
//
internal override func pulseTouches(touches: Set<NSObject>) {
super.pulseTouches(touches)
UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
self.transform = CGAffineTransformMakeScale(1.05, 1.1)
if let c = self.pulseTitleColor {
self.setTitleColor(c, forState: .Normal)
}
}) { _ in
if let c = self.titleColor {
UIView.animateWithDuration(0.3, animations: {
self.setTitleColor(c, forState: .Normal)
})
}
}
}
}
......@@ -30,6 +30,15 @@ public class MaterialButton : UIButton {
internal var pulseView: UIView?
/**
:name: backgroundColor
*/
public override var backgroundColor: UIColor? {
didSet {
backgroundColorView.backgroundColor = backgroundColor
}
}
/**
:name: pulseColor
*/
public var pulseColor: UIColor?
......@@ -120,8 +129,8 @@ public class MaterialButton : UIButton {
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
private func prepareBackgroundColorView() {
backgroundColorView.backgroundColor = backgroundColor
backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0)
}
......
......@@ -18,15 +18,48 @@
import UIKit
public class RaisedButton : FlatButton {
public class RaisedButton : MaterialButton {
/**
:name: pulseTitleColor
*/
public var pulseTitleColor: UIColor?
/**
:name: titleColor
*/
public var titleColor: UIColor? {
didSet {
setTitleColor(titleColor, forState: .Normal)
}
}
//
// :name: prepareButton
//
internal override func prepareButton() {
super.prepareButton()
backgroundColor = .redColor()
pulseColor = .whiteColor()
backgroundColorView.layer.cornerRadius = 3
}
//
// :name: pulseTouches
//
internal override func pulseTouches(touches: Set<NSObject>) {
super.pulseTouches(touches)
UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
self.transform = CGAffineTransformMakeScale(1.05, 1.1)
if let c = self.pulseTitleColor {
self.setTitleColor(c, forState: .Normal)
}
}) { _ in
if let c = self.titleColor {
UIView.animateWithDuration(0.3, animations: {
self.setTitleColor(c, forState: .Normal)
})
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment