Commit a71e5498 by Daniel Dahan

issue-7: added BasicCard to README

parent 7e5548ed
......@@ -8,13 +8,40 @@
MaterialKit is now on CocoaPods under the name [MK](https://cocoapods.org/?q=MK).
![MaterialKitPreview](http://www.materialkit.io/MaterialKitPreview.gif)
### Basic Card
Easily make cards with fully customizable components.
### Floating Action Button
![MaterialKitPreview](http://sandbox.local:3000/basiccardpreview.gif)
```swift
var button: FabButton = FabButton()
var card: BasicCard = BasicCard()
// add a title
card.titleLabel = UILabel()
card.titleLabel!.text = "Card Title"
// add a body of text
card.detailTextLabel = UILabel()
card.detailTextLabel!.text = "I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively."
// add a divider for buttons
card.divider = UIView()
// add a couple buttons
var cancelButton: FlatButton = FlatButton()
cancelButton.pulseColor = MaterialTheme.blueGrey.darken3
cancelButton.setTitle("Cancel", forState: .Normal)
cancelButton.setTitleColor(MaterialTheme.yellow.darken3, forState: .Normal)
var okButton: FlatButton = FlatButton()
okButton.pulseColor = MaterialTheme.blueGrey.darken3
okButton.setTitle("Okay", forState: .Normal)
okButton.setTitleColor(MaterialTheme.yellow.darken3, forState: .Normal)
card.buttons = [cancelButton, okButton]
view.addSubview(card)
```
### Flat Button
......
......@@ -122,6 +122,7 @@ public class BasicCard : MaterialCard {
views["divider"] = divider!
verticalFormat += "-(20)-[divider(1)]"
}
// buttons
var horizontalFormat: String = "H:|"
var buttonViews: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
......@@ -133,11 +134,14 @@ public class BasicCard : MaterialCard {
horizontalFormat += "-(10)-[button\(i)]"
layoutConstraints += Layout.constraint(verticalFormat + "-(10)-[button\(i)]-(10)-|", options: nil, metrics: nil, views: views)
}
layoutConstraints += Layout.constraint(horizontalFormat, options: nil, metrics: nil, views: buttonViews)
} else {
verticalFormat += "-(20)-|"
}
// combine constraints
if 0 < layoutConstraints.count {
layoutConstraints += Layout.constraint(verticalFormat, options: nil, metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(layoutConstraints)
......
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