Commit b8659bb0 by Daniel Dahan

updating README

parent f258b9a2
...@@ -28,9 +28,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -28,9 +28,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Table of Contents ### Table of Contents
* [MaterialColor](#materialcolor)
* [TextField](#textfield)
* [TextView](#textview)
* [MaterialLayer](#materiallayer) * [MaterialLayer](#materiallayer)
* [MaterialView](#materialview) * [MaterialView](#materialview)
* [MaterialPulseView](#materialpulseview) * [MaterialPulseView](#materialpulseview)
...@@ -46,6 +43,9 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -46,6 +43,9 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
* [Crop Image](#cropimage) * [Crop Image](#cropimage)
* [Save Image To PhotoLibrary](#saveimagetophotolibrary) * [Save Image To PhotoLibrary](#saveimagetophotolibrary)
* [Asynchronous Image Loading](#asynchronousimageloading) * [Asynchronous Image Loading](#asynchronousimageloading)
* [MaterialColor](#materialcolor)
* [TextField](#textfield)
* [TextView](#textview)
* [Lines of Text](#linesoftext) * [Lines of Text](#linesoftext)
* [Trim Whitespace](#trimwhitespace) * [Trim Whitespace](#trimwhitespace)
...@@ -63,100 +63,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -63,100 +63,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
* TimePicker * TimePicker
* More Examples * More Examples
<a name="materialcolor"/>
### MaterialColor
Explore a complete range of Material Design colors using MaterialColor. Below is an example of setting a button's background color property.
![MaterialKitMaterialColorPalette](http://www.materialkit.io/MK/MaterialKitMaterialColorPalette.png)
```swift
let button: FabButton = FabButton()
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 nameField: TextField = TextField(frame: CGRectMake(57, 100, 300, 24))
nameField.placeholder = "First Name"
nameField.font = RobotoFont.regularWithSize(20)
nameField.textColor = MaterialColor.black
nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelNormalColor = MaterialColor.grey.lighten2
nameField.titleLabelHighlightedColor = MaterialColor.blue.accent3
nameField.clearButtonMode = .WhileEditing
// Add nameField to UIViewController.
view.addSubview(nameField)
```
<a name="textview"/>
### TextView
Easily match any regular expression pattern in a body of text. Below is an example of the default hashtag pattern matching.
![MaterialKitTextView](http://www.materialkit.io/MK/MaterialKitTextView.gif)
```swift
class ViewController: UIViewController, TextDelegate, TextViewDelegate {
// ...
lazy var text: Text = Text()
var textView: TextView?
// ...
func prepareTextView() {
let layoutManager: NSLayoutManager = NSLayoutManager()
let textContainer = NSTextContainer(size: bounds.size)
layoutManager.addTextContainer(textContainer)
text.delegate = self
text.textStorage.addLayoutManager(layoutManager)
textView = TextView(frame: CGRectNull, textContainer: textContainer)
textView?.delegate = self
textView!.editable = true
textView!.selectable = true
textView!.font = UIFont.systemFontOfSize(16)
textView!.text = note?["text"] as? String
textView!.placeholderLabel = UILabel()
textView!.placeholderLabel!.textColor = UIColor.grayColor()
let attrText: NSMutableAttributedString = NSMutableAttributedString(string: "focus your #thoughts", attributes: [NSFontAttributeName: UIFont.systemFontOfSize(16)])
attrText.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(16), range: NSRange(location: 11, length: 9))
textView!.placeholderLabel!.attributedText = attrText
addSubview(textView!)
}
// ...
func textWillProcessEdit(text: Text, textStorage: TextStorage, string: String, range: NSRange) {
textStorage.removeAttribute(NSFontAttributeName, range: range)
textStorage.addAttribute(NSFontAttributeName, value: UIFont.systemFontOfSize(16), range: range)
}
//...
func textDidProcessEdit(text: Text, textStorage: TextStorage, string: String, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) {
textStorage.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(16), range: result!.range)
}
// ...
}
```
<a name="materiallayer"/> <a name="materiallayer"/>
### MaterialLayer ### MaterialLayer
...@@ -714,6 +620,100 @@ UIImage.contentsOfURL(url) { (image: UIImage?, error: NSError?) in ...@@ -714,6 +620,100 @@ UIImage.contentsOfURL(url) { (image: UIImage?, error: NSError?) in
} }
``` ```
<a name="materialcolor"/>
### MaterialColor
Explore a complete range of Material Design colors using MaterialColor. Below is an example of setting a button's background color property.
![MaterialKitMaterialColorPalette](http://www.materialkit.io/MK/MaterialKitMaterialColorPalette.png)
```swift
let button: FabButton = FabButton()
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 nameField: TextField = TextField(frame: CGRectMake(57, 100, 300, 24))
nameField.placeholder = "First Name"
nameField.font = RobotoFont.regularWithSize(20)
nameField.textColor = MaterialColor.black
nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelNormalColor = MaterialColor.grey.lighten2
nameField.titleLabelHighlightedColor = MaterialColor.blue.accent3
nameField.clearButtonMode = .WhileEditing
// Add nameField to UIViewController.
view.addSubview(nameField)
```
<a name="textview"/>
### TextView
Easily match any regular expression pattern in a body of text. Below is an example of the default hashtag pattern matching.
![MaterialKitTextView](http://www.materialkit.io/MK/MaterialKitTextView.gif)
```swift
class ViewController: UIViewController, TextDelegate, TextViewDelegate {
// ...
lazy var text: Text = Text()
var textView: TextView?
// ...
func prepareTextView() {
let layoutManager: NSLayoutManager = NSLayoutManager()
let textContainer = NSTextContainer(size: bounds.size)
layoutManager.addTextContainer(textContainer)
text.delegate = self
text.textStorage.addLayoutManager(layoutManager)
textView = TextView(frame: CGRectNull, textContainer: textContainer)
textView?.delegate = self
textView!.editable = true
textView!.selectable = true
textView!.font = UIFont.systemFontOfSize(16)
textView!.text = note?["text"] as? String
textView!.placeholderLabel = UILabel()
textView!.placeholderLabel!.textColor = UIColor.grayColor()
let attrText: NSMutableAttributedString = NSMutableAttributedString(string: "focus your #thoughts", attributes: [NSFontAttributeName: UIFont.systemFontOfSize(16)])
attrText.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(16), range: NSRange(location: 11, length: 9))
textView!.placeholderLabel!.attributedText = attrText
addSubview(textView!)
}
// ...
func textWillProcessEdit(text: Text, textStorage: TextStorage, string: String, range: NSRange) {
textStorage.removeAttribute(NSFontAttributeName, range: range)
textStorage.addAttribute(NSFontAttributeName, value: UIFont.systemFontOfSize(16), range: range)
}
//...
func textDidProcessEdit(text: Text, textStorage: TextStorage, string: String, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) {
textStorage.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(16), range: result!.range)
}
// ...
}
```
<a name="linesoftext"/> <a name="linesoftext"/>
### Lines of Text ### Lines of Text
......
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