Commit f8d2977c by Daniel Dahan

updated README with CardView example 2

parent 36c254b6
......@@ -28,7 +28,8 @@ class ViewController: UIViewController {
// Uncomment different examples and read
// the comments below.
// prepareGeneralCardView()
prepareCardViewWithoutDivider()
// prepareCardViewWithoutDivider()
prepareCardViewWithBackgroundImage()
}
/**
......@@ -127,5 +128,49 @@ class ViewController: UIViewController {
MaterialLayout.alignFromTop(view, child: cardView, top: 100)
MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
}
/**
:name: prepareCardViewWithBackgroundImage
:description: An example of the CardView with a background image.
*/
private func prepareCardViewWithBackgroundImage() {
let cardView: CardView = CardView()
cardView.dividerInsetsRef.left = 100
cardView.titleLabelInsetsRef.left = 100
cardView.detailLabelInsetsRef.left = 100
// Image.
cardView.image = UIImage(named: "MaterialKitCardViewBackgroundImage")?.resize(toWidth: 300)
cardView.contentsGravity = .TopLeft
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Focus"
titleLabel.font = RobotoFont.mediumWithSize(24)
cardView.titleLabel = titleLabel
// Detail label
let detailLabel: UILabel = UILabel()
detailLabel.text = "Easily organize your thoughts using hashtags."
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
// ITUNES button.
let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.blue.lighten1
btn1.pulseFill = true
btn1.pulseScale = false
btn1.setTitle("ITUNES", forState: .Normal)
btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
// Add buttons to right side.
cardView.rightButtons = [btn1]
// To support orientation changes, use MaterialLayout.
view.addSubview(cardView)
cardView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: cardView, top: 100)
MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
}
}
......@@ -26,6 +26,8 @@ Right out of the box to a fully customized configuration, CardView always stands
![MaterialKitCardViewDataDriven](http://www.materialkit.io/MK/MaterialKitCardViewDataDriven.gif)
![MaterialKitCardViewFocus](http://www.materialkit.io/MK/MaterialKitCardViewFocus.gif)
### License
[AGPL-3.0](http://choosealicense.com/licenses/agpl-3.0/)
......@@ -51,13 +51,13 @@ public func MaterialGravityToString(gravity: MaterialGravity) -> String {
case .Right:
return kCAGravityRight
case .TopLeft:
return kCAGravityTopLeft
return kCAGravityBottomLeft
case .TopRight:
return kCAGravityTopRight
return kCAGravityBottomRight
case .BottomLeft:
return kCAGravityBottomLeft
return kCAGravityTopLeft
case .BottomRight:
return kCAGravityBottomRight
return kCAGravityTopRight
case .Resize:
return kCAGravityResize
case .ResizeAspect:
......
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