Commit 2b0485d8 by Daniel Dahan

initial adjustment for button interface

parent dc0bee16
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'MK' s.name = 'MK'
s.version = '1.2.0' s.version = '1.3.0'
s.license = { :type => "AGPLv3+", :file => "LICENSE" } s.license = { :type => "AGPLv3+", :file => "LICENSE" }
s.summary = 'A Material Design Framework In Swift' s.summary = 'A Material Design Framework In Swift'
s.homepage = 'http://materialkit.io' s.homepage = 'http://materialkit.io'
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
import UIKit import UIKit
public class AddFabButton : FabButton { public class AddFabButton : FabButton {
/**
:name: lineWidth
*/
public var lineWidth: CGFloat = 2
private var verticalLine: UIView! private var verticalLine: UIView!
private var horizontalLine: UIView! private var horizontalLine: UIView!
......
...@@ -19,17 +19,12 @@ ...@@ -19,17 +19,12 @@
import UIKit import UIKit
public class FabButton : MaterialButton { public class FabButton : MaterialButton {
/**
:name: lineWidth
*/
public var lineWidth: CGFloat = 2
// //
// :name: prepareButton // :name: prepareButton
// //
internal override func prepareButton() { internal override func prepareButton() {
super.prepareButton() super.prepareButton()
color = .redColor() backgroundColor = .redColor()
pulseColor = .whiteColor() pulseColor = .whiteColor()
backgroundColorView.layer.cornerRadius = bounds.width / 2 backgroundColorView.layer.cornerRadius = bounds.width / 2
} }
......
...@@ -20,9 +20,18 @@ import UIKit ...@@ -20,9 +20,18 @@ import UIKit
public class FlatButton : MaterialButton { public class FlatButton : MaterialButton {
/** /**
:name: textColor :name: pulseTitleColor
*/ */
public var textColor: UIColor? public var pulseTitleColor: UIColor?
/**
:name: titleColor
*/
public var titleColor: UIColor? {
didSet {
setTitleColor(titleColor, forState: .Normal)
}
}
// //
// :name: prepareButton // :name: prepareButton
...@@ -38,11 +47,18 @@ public class FlatButton : MaterialButton { ...@@ -38,11 +47,18 @@ public class FlatButton : MaterialButton {
// //
internal override func pulseTouches(touches: Set<NSObject>) { internal override func pulseTouches(touches: Set<NSObject>) {
super.pulseTouches(touches) super.pulseTouches(touches)
textColor = titleLabel?.textColor
UIView.animateWithDuration(0.3, animations: { UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(10, 10) self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
self.transform = CGAffineTransformMakeScale(1.05, 1.1) self.transform = CGAffineTransformMakeScale(1.05, 1.1)
self.setTitleColor(UIColor.whiteColor(), forState: .Normal) 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)
})
}
}
} }
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.0</string> <string>1.3.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -30,11 +30,6 @@ public class MaterialButton : UIButton { ...@@ -30,11 +30,6 @@ public class MaterialButton : UIButton {
internal var pulseView: UIView? internal var pulseView: UIView?
/** /**
:name: color
*/
public var color: UIColor?
/**
:name: pulseColor :name: pulseColor
*/ */
public var pulseColor: UIColor? public var pulseColor: UIColor?
...@@ -125,7 +120,7 @@ public class MaterialButton : UIButton { ...@@ -125,7 +120,7 @@ public class MaterialButton : UIButton {
// We need this view so we can use the masksToBounds // We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button // so the pulse doesn't animate off the button
private func prepareBackgroundColorView() { private func prepareBackgroundColorView() {
backgroundColorView.backgroundColor = color backgroundColorView.backgroundColor = backgroundColor
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.userInteractionEnabled = false backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0) insertSubview(backgroundColorView, atIndex: 0)
......
...@@ -18,33 +18,15 @@ ...@@ -18,33 +18,15 @@
import UIKit import UIKit
public class RaisedButton : MaterialButton { public class RaisedButton : FlatButton {
/**
:name: textColor
*/
public var textColor: UIColor?
// //
// :name: prepareButton // :name: prepareButton
// //
internal override func prepareButton() { internal override func prepareButton() {
super.prepareButton() super.prepareButton()
color = .redColor() backgroundColor = .redColor()
pulseColor = .whiteColor() pulseColor = .whiteColor()
backgroundColorView.layer.cornerRadius = 3 backgroundColorView.layer.cornerRadius = 3
} }
//
// :name: pulseTouches
//
internal override func pulseTouches(touches: Set<NSObject>) {
super.pulseTouches(touches)
textColor = titleLabel?.textColor
UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
self.transform = CGAffineTransformMakeScale(1.05, 1.1)
self.setTitleColor(UIColor.whiteColor(), 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