Commit 789161bf by Daniel Dahan

CardView working with image

parent 5bf2f0a9
...@@ -480,6 +480,7 @@ public class CardView : MaterialPulseView { ...@@ -480,6 +480,7 @@ public class CardView : MaterialPulseView {
} }
} }
if nil == imageLayer.contents {
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons![0]
...@@ -502,11 +503,42 @@ public class CardView : MaterialPulseView { ...@@ -502,11 +503,42 @@ public class CardView : MaterialPulseView {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef!.bottom + titleLabelInsetsRef!.bottom + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0) metrics["insetBottom"] = contentInsetsRef!.bottom + titleLabelInsetsRef!.bottom + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInsetsRef!.bottom + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0) metrics["insetC"] = (metrics["insetTop"] as! CGFloat) + titleLabelInsetsRef!.bottom + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
} }
} else if nil != metrics["insetC"] { } else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInsetsRef!.top + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInsetsRef!.top + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
} }
} else if nil != detailLabel {
if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0]
metrics["insetC"] = leftButtonsInsetsRef!.top
metrics["insetBottom"] = contentInsetsRef!.bottom + leftButtonsInsetsRef!.bottom
} else if 0 < rightButtons?.count {
verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0]
metrics["insetC"] = rightButtonsInsetsRef!.top
metrics["insetBottom"] = contentInsetsRef!.bottom + rightButtonsInsetsRef!.bottom
}
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef!.bottom + detailLabelInsetsRef!.bottom + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInsetsRef!.bottom + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
}
} else if nil == detailLabel {
if 0 < leftButtons?.count {
verticalFormat += "-[button]"
views["button"] = leftButtons![0]
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + leftButtonsInsetsRef!.top + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
metrics["insetBottom"] = contentInsetsRef!.bottom + leftButtonsInsetsRef!.bottom
} else if 0 < rightButtons?.count {
verticalFormat += "-[button]"
views["button"] = rightButtons![0]
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + rightButtonsInsetsRef!.top + (divider ? dividerInsetsRef!.top + dividerInsetsRef!.bottom : 0)
metrics["insetBottom"] = contentInsetsRef!.bottom + rightButtonsInsetsRef!.bottom
}
}
if 0 < views.count { if 0 < views.count {
verticalFormat += "-(insetBottom)-|" verticalFormat += "-(insetBottom)-|"
......
...@@ -328,10 +328,7 @@ public class MaterialButton : UIButton { ...@@ -328,10 +328,7 @@ public class MaterialButton : UIButton {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
prepareShape() prepareShape()
prepareVisualLayer()
visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius
} }
/** /**
...@@ -375,6 +372,7 @@ public class MaterialButton : UIButton { ...@@ -375,6 +372,7 @@ public class MaterialButton : UIButton {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
} }
} }
prepareVisualLayer()
} }
/** /**
...@@ -470,6 +468,15 @@ public class MaterialButton : UIButton { ...@@ -470,6 +468,15 @@ public class MaterialButton : UIButton {
} }
// //
// :name: prepareVisualLayer
//
internal func prepareVisualLayer() {
visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius
}
//
// :name: preparePulseLayer // :name: preparePulseLayer
// //
internal func preparePulseLayer() { internal func preparePulseLayer() {
......
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