Commit 2bfceb08 by Daniel Dahan

prepare for release 1.24.4

parent 8d81d569
......@@ -11,8 +11,6 @@
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
966F57AB1C226BAA009185B7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A91C226BAA009185B7 /* LaunchScreen.storyboard */; };
966F57B31C226CA3009185B7 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 966F57B21C226CA3009185B7 /* MaterialKit.framework */; };
966F57B41C226CA3009185B7 /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 966F57B21C226CA3009185B7 /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -22,7 +20,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
966F57B41C226CA3009185B7 /* MaterialKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -36,7 +33,6 @@
966F57A71C226BAA009185B7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
966F57AA1C226BAA009185B7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
966F57AC1C226BAA009185B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
966F57B21C226CA3009185B7 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-anypxbsecgdqqxevbavirvnffqxd/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
966F57B31C226CA3009185B7 /* MaterialKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -54,7 +49,6 @@
966F57941C226BAA009185B7 = {
isa = PBXGroup;
children = (
966F57B21C226CA3009185B7 /* MaterialKit.framework */,
966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */,
);
......
......@@ -20,13 +20,15 @@ import UIKit
import MaterialKit
class ViewController: UIViewController, TextFieldDelegate {
private lazy var titleTextField: TextField = TextField()
private lazy var titleField: TextField = TextField()
private lazy var descriptionField: TextField = TextField()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareTitleTextField()
prepareTitleField()
prepareDescriptionField()
}
/**
......@@ -37,20 +39,37 @@ class ViewController: UIViewController, TextFieldDelegate {
}
/**
:name: prepareTitleTextField
:description: A preparation helper method for titleTextField.
:name: prepareTitleField
:description: A preparation helper for titleField.
*/
private func prepareTitleTextField() {
titleTextField.frame = CGRectMake(100, 100, 200, 35)
titleTextField.placeholder = "Title"
titleTextField.textColor = MaterialColor.black
titleTextField.titleLabel = UILabel()
titleTextField.titleLabel!.font = RobotoFont.boldWithSize(12)
titleTextField.font = RobotoFont.boldWithSize(24)
titleTextField.delegate = self
titleTextField.titleNormalColor = MaterialColor.grey.lighten1
titleTextField.titleHighlightedColor = MaterialColor.blue.accent3
view.addSubview(titleTextField)
private func prepareTitleField() {
titleField.delegate = self
titleField.frame = CGRectMake(57, 100, 300, 24)
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
view.addSubview(titleField)
}
/**
:name: prepareDescriptionField
:description: A preparation helper for descriptionField.
*/
private func prepareDescriptionField() {
descriptionField.delegate = self
descriptionField.frame = CGRectMake(57, 150, 300, 24)
descriptionField.placeholder = "Description"
descriptionField.font = RobotoFont.regularWithSize(20)
descriptionField.textColor = MaterialColor.black
descriptionField.titleLabel = UILabel()
descriptionField.titleLabel!.font = RobotoFont.mediumWithSize(12)
descriptionField.titleLabelNormalColor = MaterialColor.grey.lighten1
descriptionField.titleLabelHighlightedColor = MaterialColor.blue.accent3
view.addSubview(descriptionField)
}
/**
......@@ -59,9 +78,7 @@ class ViewController: UIViewController, TextFieldDelegate {
key on the keyboard.
*/
func textFieldShouldReturn(textField: UITextField) -> Bool {
if textField == titleTextField {
titleTextField.resignFirstResponder()
}
textField.resignFirstResponder()
return false
}
......
......@@ -28,6 +28,7 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Table of Contents
* [TextView](#textview)
* [MaterialColor](#materialcolor)
* [MaterialLayer](#materiallayer)
* [MaterialView](#materialview)
......@@ -43,14 +44,23 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Upcoming
* Scrolling Techniques
* TextField
* SearchBarView
* SearchBarViewController
* TabView
* TabViewController
* TextView
* Scrolling Techniques
* More Examples
<a name="textview"/>
### TextField
A TextField is a great option to increase UX. Below is an example.
Space on mobile devices
![MaterialKitTextField](http://www.materialkit.io/MK/MaterialKitTextField.gif)
<a name="materialcolor"/>
### MaterialColor
......
......@@ -27,23 +27,18 @@ public class TextField : UITextField {
private var count: Int?
/**
:name: titleNormalColor
:name: titleLabelNormalColor
*/
public var titleNormalColor: UIColor? {
public var titleLabelNormalColor: UIColor? {
didSet {
titleLabel?.textColor = titleNormalColor
titleLabel?.textColor = titleLabelNormalColor
}
}
/**
:name: titleHighlightedColor
:name: titleLabelHighlightedColor
*/
public var titleHighlightedColor: UIColor?
/**
:name: bottomBorderLayer
*/
public private(set) lazy var bottomBorderLayer: MaterialLayer = MaterialLayer()
public var titleLabelHighlightedColor: UIColor?
/**
:name: titleLabel
......@@ -83,19 +78,10 @@ public class TextField : UITextField {
}
/**
:name: layoutSubviews
*/
public override func layoutSubviews() {
super.layoutSubviews()
bottomBorderLayer.frame = CGRectMake(0, bounds.height - bottomBorderLayer.height, bounds.width, bottomBorderLayer.height)
}
/**
:name: prepareView
*/
public func prepareView() {
clipsToBounds = false
prepareBottomBorderLayer()
}
/**
......@@ -103,7 +89,7 @@ public class TextField : UITextField {
*/
internal func textFieldDidBegin(textField: TextField) {
count = text?.utf16.count
titleLabel?.textColor = titleHighlightedColor
titleLabel?.textColor = 0 == count ? titleLabelNormalColor : titleLabelHighlightedColor
}
/**
......@@ -112,17 +98,18 @@ public class TextField : UITextField {
internal func textFieldDidChange(textField: TextField) {
if 0 == count && 1 == text?.utf16.count {
if let v: UILabel = titleLabel {
v.hidden = false
UIView.animateWithDuration(0.25, animations: {
v.hidden = false
v.alpha = 1
v.frame.origin.y = -v.frame.height
})
titleLabel?.textColor = titleLabelHighlightedColor
}
} else if 1 == count && 0 == text?.utf16.count {
if let v: UILabel = titleLabel {
UIView.animateWithDuration(0.25, animations: {
v.alpha = 0
v.frame.origin.y = -v.frame.height / 3
v.frame.origin.y = -v.frame.height + 4
}) { _ in
v.hidden = true
}
......@@ -137,8 +124,8 @@ public class TextField : UITextField {
internal func textFieldDidEnd(textField: TextField) {
if 0 < count {
if let v: UILabel = titleLabel {
v.hidden = false
UIView.animateWithDuration(0.25, animations: {
v.hidden = false
v.alpha = 1
v.frame.origin.y = -v.frame.height
})
......@@ -147,22 +134,13 @@ public class TextField : UITextField {
if let v: UILabel = titleLabel {
UIView.animateWithDuration(0.25, animations: {
v.alpha = 0
v.frame.origin.y = -v.frame.height / 3
}) { _ in
v.hidden = true
v.frame.origin.y = -v.frame.height + 4
}) { _ in
v.hidden = true
}
}
}
titleLabel?.textColor = titleNormalColor
}
/**
:name: prepareBottomBorderLayer
*/
private func prepareBottomBorderLayer() {
bottomBorderLayer.frame = CGRectMake(0, bounds.height + 5, bounds.width, 3)
bottomBorderLayer.backgroundColor = MaterialColor.grey.lighten3.CGColor
layer.addSublayer(bottomBorderLayer)
titleLabel?.textColor = titleLabelNormalColor
}
/**
......
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