Commit b1c2ce77 by Daniel Dahan

issue-307: Added lineLayerThickness and lineLayerActiveThickness to TextField in…

issue-307: Added lineLayerThickness and lineLayerActiveThickness to TextField in order to adjust lineLayer during different states
parent ee64ef6d
......@@ -11,6 +11,8 @@
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 */; };
96977E271CBE9CC4000BEFC4 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96977E261CBE9CC4000BEFC4 /* Material.framework */; };
96977E281CBE9CC4000BEFC4 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96977E261CBE9CC4000BEFC4 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96977E281CBE9CC4000BEFC4 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -33,6 +36,7 @@
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>"; };
96977E261CBE9CC4000BEFC4 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-bshwisidfobstlbomegqyybbrygh/Build/Products/Debug-iphonesimulator/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96977E271CBE9CC4000BEFC4 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
966F57941C226BAA009185B7 = {
isa = PBXGroup;
children = (
96977E261CBE9CC4000BEFC4 /* Material.framework */,
966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */,
);
......
......@@ -76,6 +76,10 @@ class ViewController: UIViewController, TextFieldDelegate {
textField.detailLabel!.text = "Email is incorrect."
textField.detailLabel!.font = RobotoFont.regularWithSize(12)
textField.detailLabelActiveColor = MaterialColor.red.accent3
textField.lineLayerThickness = 3
textField.lineLayerActiveThickness = 5
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
view.addSubview(textField)
......
......@@ -259,6 +259,12 @@ public class TextField : UITextField {
*/
@IBInspectable public var lineLayerDistance: CGFloat = 4
/// The height of the line when not active.
@IBInspectable public var lineLayerThickness: CGFloat = 1
/// The height of the line when active.
@IBInspectable public var lineLayerActiveThickness: CGFloat = 2
/// The lineLayer color when inactive.
@IBInspectable public var lineLayerColor: UIColor? {
didSet {
......@@ -500,8 +506,7 @@ public class TextField : UITextField {
/// Reloads the view.
public func reloadView() {
/// Align the clearButton.
clearButton.frame = CGRectMake(width - height, 2, height - 4, height - 4)
// clearButton.frame = CGRectMake(width - height, 0, height, height)
}
......@@ -526,7 +531,7 @@ public class TextField : UITextField {
internal func textFieldDidBegin() {
showTitleLabel()
titleLabel.textColor = titleLabelActiveColor
lineLayer.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, 2)
lineLayer.frame.size.height = lineLayerActiveThickness
lineLayer.backgroundColor = (detailLabelHidden ? nil == lineLayerActiveColor ? titleLabelActiveColor : lineLayerActiveColor : nil == lineLayerDetailActiveColor ? detailLabelActiveColor : lineLayerDetailActiveColor)?.CGColor
}
......@@ -543,7 +548,7 @@ public class TextField : UITextField {
hideTitleLabel()
}
titleLabel.textColor = titleLabelColor
lineLayer.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, 1)
lineLayer.frame.size.height = lineLayerThickness
lineLayer.backgroundColor = (detailLabelHidden ? nil == lineLayerColor ? titleLabelColor : lineLayerColor : nil == lineLayerDetailColor ? detailLabelActiveColor : lineLayerDetailColor)?.CGColor
}
......@@ -598,7 +603,7 @@ public class TextField : UITextField {
/// Layout the lineLayer.
private func layoutLineLayer() {
let h: CGFloat = 1 < lineLayer.frame.height ? lineLayer.frame.height : 1
let h: CGFloat = lineLayerActiveThickness == lineLayer.frame.height ? lineLayerActiveThickness : lineLayerThickness
lineLayer.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, h)
}
......
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