Commit c05511dc by Daniel Dahan

added lineLayer colors

parent 588b6f70
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96BCB86A1CB4B3D700C806FE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96BCB8691CB4B3D700C806FE /* Material.framework */; };
96BCB86B1CB4B3D700C806FE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96BCB8691CB4B3D700C806FE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96F2F1E51C97A5C800A5FE27 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1DF1C97A5C800A5FE27 /* AppDelegate.swift */; }; 96F2F1E51C97A5C800A5FE27 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1DF1C97A5C800A5FE27 /* AppDelegate.swift */; };
96F2F1E61C97A5C800A5FE27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1E01C97A5C800A5FE27 /* Assets.xcassets */; }; 96F2F1E61C97A5C800A5FE27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1E01C97A5C800A5FE27 /* Assets.xcassets */; };
96F2F1E71C97A5C800A5FE27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1E11C97A5C800A5FE27 /* LaunchScreen.storyboard */; }; 96F2F1E71C97A5C800A5FE27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1E11C97A5C800A5FE27 /* LaunchScreen.storyboard */; };
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96BCB86B1CB4B3D700C806FE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -31,7 +28,6 @@ ...@@ -31,7 +28,6 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96A71F041C718F8800C0C4AE /* SearchBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SearchBar.app; sourceTree = BUILT_PRODUCTS_DIR; }; 96A71F041C718F8800C0C4AE /* SearchBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SearchBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
96BCB8691CB4B3D700C806FE /* 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>"; };
96F2F1DF1C97A5C800A5FE27 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 96F2F1DF1C97A5C800A5FE27 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96F2F1E01C97A5C800A5FE27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96F2F1E01C97A5C800A5FE27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96F2F1E21C97A5C800A5FE27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96F2F1E21C97A5C800A5FE27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96BCB86A1CB4B3D700C806FE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
96A71EFB1C718F8800C0C4AE = { 96A71EFB1C718F8800C0C4AE = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96BCB8691CB4B3D700C806FE /* Material.framework */,
96F2F1DE1C97A5C800A5FE27 /* SearchBar */, 96F2F1DE1C97A5C800A5FE27 /* SearchBar */,
96A71F051C718F8800C0C4AE /* Products */, 96A71F051C718F8800C0C4AE /* Products */,
); );
......
...@@ -37,7 +37,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -37,7 +37,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = AppSearchBarController(rootViewController: YellowViewController()) window!.rootViewController = AppSearchBarController(rootViewController: YellowViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
return true return true
......
...@@ -53,23 +53,16 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -53,23 +53,16 @@ class ViewController: UIViewController, TextFieldDelegate {
/// Prepares the name TextField. /// Prepares the name TextField.
private func prepareNameField() { private func prepareNameField() {
let textField: TextField = TextField(frame: CGRectMake(57, 100, 300, 24)) let textField: TextField = TextField(frame: CGRectMake(57, 100, 300, 32))
textField.placeholder = "First Name" textField.placeholder = "First Name"
textField.placeholderTextColor = MaterialColor.grey.base
textField.font = RobotoFont.regularWithSize(20)
textField.textColor = MaterialColor.black
view.addSubview(textField) view.addSubview(textField)
} }
/// Prepares the email TextField. /// Prepares the email TextField.
private func prepareEmailField() { private func prepareEmailField() {
let textField: TextField = TextField(frame: CGRectMake(57, 200, 300, 24)) let textField: TextField = TextField(frame: CGRectMake(57, 200, 300, 32))
textField.delegate = self textField.delegate = self
textField.placeholder = "Email" textField.placeholder = "Email"
textField.placeholderTextColor = MaterialColor.grey.base
textField.font = RobotoFont.regularWithSize(20)
textField.textColor = MaterialColor.black
/* /*
Used to display the error message, which is displayed when Used to display the error message, which is displayed when
...@@ -79,7 +72,7 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -79,7 +72,7 @@ class ViewController: UIViewController, TextFieldDelegate {
textField.detailLabel!.text = "Email is incorrect." textField.detailLabel!.text = "Email is incorrect."
textField.detailLabel!.font = RobotoFont.mediumWithSize(12) textField.detailLabel!.font = RobotoFont.mediumWithSize(12)
textField.detailLabelActiveColor = MaterialColor.red.accent3 textField.detailLabelActiveColor = MaterialColor.red.accent3
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding. textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
view.addSubview(textField) view.addSubview(textField)
} }
......
...@@ -57,20 +57,12 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -57,20 +57,12 @@ class ViewController: UIViewController, TextFieldDelegate {
/// Prepares the name TextField. /// Prepares the name TextField.
private func prepareNameField() { private func prepareNameField() {
nameField.placeholder = "First Name" nameField.placeholder = "First Name"
nameField.placeholderTextColor = MaterialColor.grey.base
nameField.font = RobotoFont.regularWithSize(20)
nameField.textColor = MaterialColor.black
nameField.borderStyle = .None
} }
/// Prepares the email TextField. /// Prepares the email TextField.
private func prepareEmailField() { private func prepareEmailField() {
emailField.delegate = self emailField.delegate = self
emailField.placeholder = "Email" emailField.placeholder = "Email"
emailField.placeholderTextColor = MaterialColor.grey.base
emailField.font = RobotoFont.regularWithSize(20)
emailField.textColor = MaterialColor.black
emailField.borderStyle = .None
/* /*
Used to display the error message, which is displayed when Used to display the error message, which is displayed when
......
...@@ -365,9 +365,11 @@ Add a new dimension of interactivity with CaptureView. CaptureView is a fully fu ...@@ -365,9 +365,11 @@ Add a new dimension of interactivity with CaptureView. CaptureView is a fully fu
* TabBarController * TabBarController
* Scrolling Techniques * Scrolling Techniques
* Snackbar * Snackbar
* BottomNavigationController with Snackbar.
* Bottom Sheets * Bottom Sheets
* Dialogs * Dialogs
* Collapsing Toolbar * Collapsing Toolbar
* RTL Support
* Advanced Camera / Audio Toolset & Views * Advanced Camera / Audio Toolset & Views
* More Examples * More Examples
......
...@@ -125,7 +125,7 @@ public class SearchBar : StatusBarView { ...@@ -125,7 +125,7 @@ public class SearchBar : StatusBarView {
textField.font = RobotoFont.regularWithSize(20) textField.font = RobotoFont.regularWithSize(20)
textField.backgroundColor = MaterialColor.clear textField.backgroundColor = MaterialColor.clear
textField.clearButtonMode = .WhileEditing textField.clearButtonMode = .WhileEditing
tintColor = MaterialColor.grey.darken4 tintColor = MaterialColor.grey.base
textColor = MaterialColor.grey.darken4 textColor = MaterialColor.grey.darken4
placeholder = "Search" placeholder = "Search"
placeholderTextColor = MaterialColor.grey.base placeholderTextColor = MaterialColor.grey.base
...@@ -139,7 +139,7 @@ public class SearchBar : StatusBarView { ...@@ -139,7 +139,7 @@ public class SearchBar : StatusBarView {
clearButton.contentEdgeInsets = UIEdgeInsetsZero clearButton.contentEdgeInsets = UIEdgeInsetsZero
clearButton.pulseColor = MaterialColor.grey.base clearButton.pulseColor = MaterialColor.grey.base
clearButton.pulseScale = false clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.grey.darken4 clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal) clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted) clearButton.setImage(image, forState: .Highlighted)
clearButtonAutoHandleEnabled = true clearButtonAutoHandleEnabled = true
......
...@@ -34,6 +34,9 @@ public protocol TextFieldDelegate : UITextFieldDelegate {} ...@@ -34,6 +34,9 @@ public protocol TextFieldDelegate : UITextFieldDelegate {}
@IBDesignable @IBDesignable
public class TextField : UITextField { public class TextField : UITextField {
/// A reference to the placeholder value.
private var placeholderText: String?
/** /**
This property is the same as clipsToBounds. It crops any of the view's This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. contents from bleeding past the view's frame.
...@@ -248,13 +251,29 @@ public class TextField : UITextField { ...@@ -248,13 +251,29 @@ public class TextField : UITextField {
public private(set) var clearButton: FlatButton! public private(set) var clearButton: FlatButton!
/// The bottom border layer. /// The bottom border layer.
public private(set) lazy var bottomBorderLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var lineLayer: CAShapeLayer = CAShapeLayer()
/** /**
A property that sets the distance between the textField and A property that sets the distance between the textField and
bottomBorderLayer. lineLayer.
*/ */
@IBInspectable public var bottomBorderLayerDistance: CGFloat = 4 @IBInspectable public var lineLayerDistance: CGFloat = 4
/// The lineLayer color when inactive.
@IBInspectable public var lineLayerColor: UIColor? {
didSet {
lineLayer.backgroundColor = lineLayerColor?.CGColor
}
}
/// The lineLayer active color.
@IBInspectable public var lineLayerActiveColor: UIColor?
/// The lineLayer detail color when inactive.
@IBInspectable public var lineLayerDetailColor: UIColor?
/// The lineLayer detail active color.
@IBInspectable public var lineLayerDetailActiveColor: UIColor?
/** /**
The title UILabel that is displayed when there is text. The The title UILabel that is displayed when there is text. The
...@@ -267,20 +286,26 @@ public class TextField : UITextField { ...@@ -267,20 +286,26 @@ public class TextField : UITextField {
@IBInspectable public var titleLabelColor: UIColor? { @IBInspectable public var titleLabelColor: UIColor? {
didSet { didSet {
titleLabel.textColor = titleLabelColor titleLabel.textColor = titleLabelColor
MaterialAnimation.animationDisabled { [unowned self] in if nil == lineLayerColor {
self.bottomBorderLayer.backgroundColor = self.titleLabelColor?.CGColor lineLayerColor = titleLabelColor
} }
} }
} }
/// The color of the titleLabel text when the textField is active. /// The color of the titleLabel text when the textField is active.
@IBInspectable public var titleLabelActiveColor: UIColor? @IBInspectable public var titleLabelActiveColor: UIColor? {
didSet {
if nil == lineLayerActiveColor {
lineLayerActiveColor = titleLabelActiveColor
}
}
}
/** /**
A property that sets the distance between the textField and A property that sets the distance between the textField and
titleLabel. titleLabel.
*/ */
@IBInspectable public var titleLabelAnimationDistance: CGFloat = 8 @IBInspectable public var titleLabelAnimationDistance: CGFloat = 4
/// An override to the text property. /// An override to the text property.
@IBInspectable public override var text: String? { @IBInspectable public override var text: String? {
...@@ -307,8 +332,8 @@ public class TextField : UITextField { ...@@ -307,8 +332,8 @@ public class TextField : UITextField {
didSet { didSet {
if !detailLabelHidden { if !detailLabelHidden {
detailLabel?.textColor = detailLabelActiveColor detailLabel?.textColor = detailLabelActiveColor
MaterialAnimation.animationDisabled { [unowned self] in if nil == lineLayerDetailActiveColor {
self.bottomBorderLayer.backgroundColor = self.detailLabelActiveColor?.CGColor lineLayerDetailActiveColor = detailLabelActiveColor
} }
} }
} }
...@@ -333,15 +358,11 @@ public class TextField : UITextField { ...@@ -333,15 +358,11 @@ public class TextField : UITextField {
didSet { didSet {
if detailLabelHidden { if detailLabelHidden {
detailLabel?.textColor = titleLabelColor detailLabel?.textColor = titleLabelColor
MaterialAnimation.animationDisabled { [unowned self] in lineLayer.backgroundColor = (editing ? lineLayerActiveColor : lineLayerColor)?.CGColor
self.bottomBorderLayer.backgroundColor = self.editing ? self.titleLabelActiveColor?.CGColor : self.titleLabelColor?.CGColor
}
hideDetailLabel() hideDetailLabel()
} else { } else {
detailLabel?.textColor = detailLabelActiveColor detailLabel?.textColor = detailLabelActiveColor
MaterialAnimation.animationDisabled { [unowned self] in lineLayer.backgroundColor = (nil == lineLayerDetailActiveColor ? detailLabelActiveColor : lineLayerDetailActiveColor)?.CGColor
self.bottomBorderLayer.backgroundColor = self.detailLabelActiveColor?.CGColor
}
showDetailLabel() showDetailLabel()
} }
} }
...@@ -394,7 +415,7 @@ public class TextField : UITextField { ...@@ -394,7 +415,7 @@ public class TextField : UITextField {
public override func layoutSublayersOfLayer(layer: CALayer) { public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
bottomBorderLayer.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, 1) layoutLineLayer()
layoutShadowPath() layoutShadowPath()
} }
} }
...@@ -463,9 +484,13 @@ public class TextField : UITextField { ...@@ -463,9 +484,13 @@ public class TextField : UITextField {
public func prepareView() { public func prepareView() {
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
masksToBounds = false masksToBounds = false
prepareBottomBorderLayer() placeholderTextColor = MaterialColor.grey.base
font = RobotoFont.regularWithSize(20)
textColor = MaterialColor.grey.darken4
borderStyle = .None
prepareClearButton() prepareClearButton()
prepareTitleLabel() prepareTitleLabel()
prepareLineLayer()
reloadView() reloadView()
} }
...@@ -485,27 +510,20 @@ public class TextField : UITextField { ...@@ -485,27 +510,20 @@ public class TextField : UITextField {
internal func textFieldValueChanged() { internal func textFieldValueChanged() {
if detailLabelAutoHideEnabled && !detailLabelHidden { if detailLabelAutoHideEnabled && !detailLabelHidden {
detailLabelHidden = true detailLabelHidden = true
MaterialAnimation.animationDisabled { [unowned self] in lineLayer.backgroundColor = (nil == lineLayerActiveColor ? titleLabelActiveColor : lineLayerActiveColor)?.CGColor
self.bottomBorderLayer.backgroundColor = self.titleLabelActiveColor?.CGColor
}
} }
} }
/// Handler for text editing began. /// Handler for text editing began.
internal func textFieldDidBegin() { internal func textFieldDidBegin() {
showTitleLabel()
titleLabel.textColor = titleLabelActiveColor titleLabel.textColor = titleLabelActiveColor
MaterialAnimation.animationDisabled { [unowned self] in lineLayer.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, 2)
self.bottomBorderLayer.backgroundColor = self.detailLabelHidden ? self.titleLabelActiveColor?.CGColor : self.detailLabelActiveColor?.CGColor lineLayer.backgroundColor = (detailLabelHidden ? nil == lineLayerActiveColor ? titleLabelActiveColor : lineLayerActiveColor : nil == lineLayerDetailActiveColor ? detailLabelActiveColor : lineLayerDetailActiveColor)?.CGColor
}
} }
/// Handler for text changed. /// Handler for text changed.
internal func textFieldDidChange() { internal func textFieldDidChange() {
if 0 < text?.utf16.count {
showTitleLabel()
} else if 0 == text?.utf16.count {
hideTitleLabel()
}
sendActionsForControlEvents(.ValueChanged) sendActionsForControlEvents(.ValueChanged)
} }
...@@ -517,9 +535,8 @@ public class TextField : UITextField { ...@@ -517,9 +535,8 @@ public class TextField : UITextField {
hideTitleLabel() hideTitleLabel()
} }
titleLabel.textColor = titleLabelColor titleLabel.textColor = titleLabelColor
MaterialAnimation.animationDisabled { [unowned self] in lineLayer.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, 1)
self.bottomBorderLayer.backgroundColor = self.detailLabelHidden ? self.titleLabelColor?.CGColor : self.detailLabelActiveColor?.CGColor lineLayer.backgroundColor = (detailLabelHidden ? nil == lineLayerColor ? titleLabelColor : lineLayerColor : nil == lineLayerDetailColor ? detailLabelActiveColor : lineLayerDetailColor)?.CGColor
}
} }
/// Sets the shadow path. /// Sets the shadow path.
...@@ -535,7 +552,7 @@ public class TextField : UITextField { ...@@ -535,7 +552,7 @@ public class TextField : UITextField {
} }
} }
/// Prepares the titleLabel property. /// Prepares the titleLabel.
private func prepareTitleLabel() { private func prepareTitleLabel() {
titleLabel = UILabel() titleLabel = UILabel()
titleLabel.hidden = true titleLabel.hidden = true
...@@ -554,7 +571,7 @@ public class TextField : UITextField { ...@@ -554,7 +571,7 @@ public class TextField : UITextField {
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd) addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd)
} }
/// Prepares the detailLabel property. /// Prepares the detailLabel.
private func prepareDetailLabel() { private func prepareDetailLabel() {
if let v: UILabel = detailLabel { if let v: UILabel = detailLabel {
v.hidden = true v.hidden = true
...@@ -573,9 +590,16 @@ public class TextField : UITextField { ...@@ -573,9 +590,16 @@ public class TextField : UITextField {
} }
} }
/// Prepares the bottomBorderLayer property. /// Prepares the lineLayer.
private func prepareBottomBorderLayer() { private func prepareLineLayer() {
layer.addSublayer(bottomBorderLayer) layoutLineLayer()
layer.addSublayer(lineLayer)
}
/// Layout the lineLayer.
private func layoutLineLayer() {
let h: CGFloat = 1 < lineLayer.frame.height ? lineLayer.frame.height : 1
lineLayer.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, h)
} }
/// Prepares the clearButton. /// Prepares the clearButton.
...@@ -598,26 +622,29 @@ public class TextField : UITextField { ...@@ -598,26 +622,29 @@ public class TextField : UITextField {
private func showTitleLabel() { private func showTitleLabel() {
if titleLabel.hidden { if titleLabel.hidden {
if let s: String = placeholder { if let s: String = placeholder {
if 0 == titleLabel.text?.utf16.count || nil == titleLabel.text { titleLabel.text = s
titleLabel.text = s placeholderText = s
} placeholder = nil
} }
let h: CGFloat = ceil(titleLabel.font.lineHeight) let h: CGFloat = ceil(titleLabel.font.lineHeight)
titleLabel.frame = CGRectMake(0, -h, bounds.width, h) titleLabel.frame = bounds
titleLabel.font = font
titleLabel.hidden = false titleLabel.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [unowned self] in
self.titleLabel.alpha = 1 self.titleLabel.alpha = 1
self.titleLabel.frame.origin.y -= self.titleLabelAnimationDistance self.titleLabel.font = self.font?.fontWithSize(12)
self.titleLabel.frame = CGRectMake(0, -(self.titleLabelAnimationDistance + h), self.bounds.width, h)
}) })
} }
} }
/// Hides and animates the titleLabel property. /// Hides and animates the titleLabel property.
private func hideTitleLabel() { private func hideTitleLabel() {
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [unowned self] in
self.titleLabel.alpha = 0 self.titleLabel.font = self.font
self.titleLabel.frame.origin.y += self.titleLabelAnimationDistance self.titleLabel.frame = self.bounds
}) { _ in }) { [unowned self] _ in
self.placeholder = self.placeholderText
self.titleLabel.hidden = true self.titleLabel.hidden = true
} }
} }
...@@ -627,10 +654,10 @@ public class TextField : UITextField { ...@@ -627,10 +654,10 @@ public class TextField : UITextField {
if let v: UILabel = detailLabel { if let v: UILabel = detailLabel {
if v.hidden { if v.hidden {
let h: CGFloat = ceil(v.font.lineHeight) let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, h) v.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, h)
v.hidden = false v.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [unowned self] in
v.frame.origin.y = self.frame.height + self.bottomBorderLayerDistance + self.detailLabelAnimationDistance v.frame.origin.y = self.frame.height + self.lineLayerDistance + self.detailLabelAnimationDistance
v.alpha = 1 v.alpha = 1
}) })
} }
...@@ -640,7 +667,7 @@ public class TextField : UITextField { ...@@ -640,7 +667,7 @@ public class TextField : UITextField {
/// Hides and animates the detailLabel property. /// Hides and animates the detailLabel property.
private func hideDetailLabel() { private func hideDetailLabel() {
if let v: UILabel = detailLabel { if let v: UILabel = detailLabel {
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [unowned self] in
v.alpha = 0 v.alpha = 0
v.frame.origin.y -= self.detailLabelAnimationDistance v.frame.origin.y -= self.detailLabelAnimationDistance
}) { _ in }) { _ in
......
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