Commit 789161bf by Daniel Dahan

CardView working with image

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