Commit a5c2a3df by Daniel Dahan

updated README with TextField

parent ab0f186c
...@@ -29,10 +29,10 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -29,10 +29,10 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Table of Contents ### Table of Contents
* [MaterialColor](#materialcolor) * [MaterialColor](#materialcolor)
* [TextField](#textfield)
* [MaterialLayer](#materiallayer) * [MaterialLayer](#materiallayer)
* [MaterialView](#materialview) * [MaterialView](#materialview)
* [MaterialPulseView](#materialpulseview) * [MaterialPulseView](#materialpulseview)
* [TextField](#textfield)
* [FlatButton](#flatbutton) * [FlatButton](#flatbutton)
* [RaisedButton](#raisedbutton) * [RaisedButton](#raisedbutton)
* [FabButton](#fabbutton) * [FabButton](#fabbutton)
...@@ -64,6 +64,28 @@ let button: FabButton = FabButton() ...@@ -64,6 +64,28 @@ let button: FabButton = FabButton()
button.backgroundColor = MaterialColor.blue.darken1 button.backgroundColor = MaterialColor.blue.darken1
``` ```
<a name="textfield"/>
### TextField
A TextField is an excellent way to improve UX. Checkout the Examples directory for a project using this component.
![MaterialKitTextField](http://www.materialkit.io/MK/MaterialKitTextField.gif)
```swift
let titleField: TextField = TextField(frame: CGRectMake(57, 100, 300, 24))
titleField.delegate = self
titleField.placeholder = "Title"
titleField.font = RobotoFont.regularWithSize(20)
titleField.textColor = MaterialColor.black
titleField.titleLabel = UILabel()
titleField.titleLabel!.font = RobotoFont.mediumWithSize(12)
titleField.titleLabelNormalColor = MaterialColor.grey.lighten1
titleField.titleLabelHighlightedColor = MaterialColor.blue.accent3
// Add titleField to UIViewController.
view.addSubview(titleField)
```
<a name="materiallayer"/> <a name="materiallayer"/>
### MaterialLayer ### MaterialLayer
...@@ -116,13 +138,6 @@ materialPulseView.shadowDepth = .Depth2 ...@@ -116,13 +138,6 @@ materialPulseView.shadowDepth = .Depth2
view.addSubview(materialPulseView) view.addSubview(materialPulseView)
``` ```
<a name="textfield"/>
### TextField
A TextField is an excellent way to improve UX. Checkout the Examples directory for a project using this component.
![MaterialKitTextField](http://www.materialkit.io/MK/MaterialKitTextField.gif)
<a name="flatbutton"/> <a name="flatbutton"/>
### FlatButton ### FlatButton
......
...@@ -153,6 +153,7 @@ public class TextField : UITextField { ...@@ -153,6 +153,7 @@ public class TextField : UITextField {
v.hidden = true v.hidden = true
v.alpha = 0 v.alpha = 0
} }
titleLabel?.text = placeholder
let h: CGFloat = v.font.stringSize(v.text!, constrainedToWidth: Double(bounds.width)).height let h: CGFloat = v.font.stringSize(v.text!, constrainedToWidth: Double(bounds.width)).height
v.frame = CGRectMake(0, -h, bounds.width, h) v.frame = CGRectMake(0, -h, bounds.width, h)
addSubview(v) addSubview(v)
......
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