Commit dd56c12a by Daniel Dahan

issue-7: MaterialCard working with pulse

parent 8eed8b5d
...@@ -33,7 +33,8 @@ public class BasicCard : MaterialCard { ...@@ -33,7 +33,8 @@ public class BasicCard : MaterialCard {
prepareTitleLabel() prepareTitleLabel()
prepareDetailTextLabel() prepareDetailTextLabel()
prepareHorizontalSeparator() prepareHorizontalSeparator()
prepareButtons() prepareCancelButton()
prepareOtherButton()
addConstraints(Layout.constraint("H:|-(20)-[titleLabel]-(20)-|", options: nil, metrics: nil, views: ["titleLabel": titleLabel])) addConstraints(Layout.constraint("H:|-(20)-[titleLabel]-(20)-|", options: nil, metrics: nil, views: ["titleLabel": titleLabel]))
addConstraints(Layout.constraint("H:|-(20)-[detailTextLabel]-(20)-|", options: nil, metrics: nil, views: ["detailTextLabel": detailTextLabel])) addConstraints(Layout.constraint("H:|-(20)-[detailTextLabel]-(20)-|", options: nil, metrics: nil, views: ["detailTextLabel": detailTextLabel]))
addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: ["horizontalSeparator": horizontalSeparator])) addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: ["horizontalSeparator": horizontalSeparator]))
...@@ -66,12 +67,7 @@ public class BasicCard : MaterialCard { ...@@ -66,12 +67,7 @@ public class BasicCard : MaterialCard {
horizontalSeparator.alpha = 0.2 horizontalSeparator.alpha = 0.2
addSubview(horizontalSeparator) addSubview(horizontalSeparator)
} }
private func prepareButtons() {
prepareCancelButton()
prepareOtherButton()
}
private func prepareCancelButton() { private func prepareCancelButton() {
cancelButton.setTranslatesAutoresizingMaskIntoConstraints(false) cancelButton.setTranslatesAutoresizingMaskIntoConstraints(false)
cancelButton.setTitle("Cancel", forState: .Normal) cancelButton.setTitle("Cancel", forState: .Normal)
......
...@@ -55,6 +55,15 @@ public struct Layout { ...@@ -55,6 +55,15 @@ public struct Layout {
} }
/** /**
:name: expandToParentSizeWithPad
*/
public static func expandToParentSizeWithPad(parent: UIView, child: UIView, left: CGFloat, bottom: CGFloat, right: CGFloat, top: CGFloat) {
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: views))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: views))
}
/**
:name: alignFromTopLeft :name: alignFromTopLeft
*/ */
public static func alignFromTopLeft(parent: UIView, child: UIView, top: CGFloat, left: CGFloat) { public static func alignFromTopLeft(parent: UIView, child: UIView, top: CGFloat, left: CGFloat) {
......
...@@ -136,8 +136,8 @@ public class MaterialCard : UIView { ...@@ -136,8 +136,8 @@ public class MaterialCard : UIView {
pulseView!.backgroundColor = pulseColor.colorWithAlphaComponent(0.5) pulseView!.backgroundColor = pulseColor.colorWithAlphaComponent(0.5)
backgroundColorView.addSubview(pulseView!) backgroundColorView.addSubview(pulseView!)
UIView.animateWithDuration(0.3, animations: { UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(3, 3) self.pulseView!.transform = CGAffineTransformMakeScale(3, 3)
self.transform = CGAffineTransformMakeScale(15, 15) self.transform = CGAffineTransformMakeScale(1.05, 1.05)
}, completion: nil) }, completion: nil)
} }
...@@ -165,7 +165,6 @@ public class MaterialCard : UIView { ...@@ -165,7 +165,6 @@ public class MaterialCard : UIView {
backgroundColorView.setTranslatesAutoresizingMaskIntoConstraints(false) backgroundColorView.setTranslatesAutoresizingMaskIntoConstraints(false)
backgroundColorView.layer.cornerRadius = 2 backgroundColorView.layer.cornerRadius = 2
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0) insertSubview(backgroundColorView, atIndex: 0)
Layout.expandToParentSize(self, child: backgroundColorView) Layout.expandToParentSize(self, child: backgroundColorView)
......
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