Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
85cae46a
Commit
85cae46a
authored
Apr 26, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-338: fixed where programmatically setting text did not display placeholderLabel
parent
23dde70e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
Examples/Programmatic/TextField/TextField/ViewController.swift
+2
-2
Sources/iOS/MTextField.swift
+18
-13
No files found.
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
85cae46a
...
...
@@ -106,9 +106,9 @@ class ViewController: UIViewController, TextFieldDelegate {
/// Prepares the name TextField.
private
func
prepareNameField
()
{
nameField
=
MTextField
()
nameField
.
placeholder
=
"Name"
nameField
.
placeholder
=
"Name
yyy yyy
"
nameField
.
detail
=
"Error, incorrect password. yy ypp ggg"
nameField
.
placeholderTextColor
=
MaterialColor
.
green
.
base
nameField
.
text
=
"Testing Text ppp ppp"
view
.
addSubview
(
nameField
)
nameField
.
translatesAutoresizingMaskIntoConstraints
=
false
...
...
Sources/iOS/MTextField.swift
View file @
85cae46a
...
...
@@ -259,7 +259,9 @@ public class MTextField : UITextField {
/// Handles the text editing did end state.
public
func
handleEditingDidEnd
()
{
dividerEditingDidEndAnimation
()
placeholderEditingDidEndAnimation
()
if
true
==
text
?
.
isEmpty
{
placeholderEditingDidEndAnimation
()
}
}
/**
...
...
@@ -290,6 +292,10 @@ public class MTextField : UITextField {
public
func
layoutPlaceholderLabel
()
{
if
true
==
text
?
.
isEmpty
{
placeholderLabel
.
frame
=
bounds
}
else
if
CGAffineTransformIsIdentity
(
placeholderLabel
.
transform
)
{
placeholderLabel
.
frame
=
bounds
placeholderLabel
.
transform
=
CGAffineTransformScale
(
placeholderLabel
.
transform
,
0.75
,
0.75
)
placeholderLabel
.
frame
.
origin
=
CGPointMake
(
0
,
-
16
)
}
}
...
...
@@ -314,11 +320,11 @@ public class MTextField : UITextField {
/// The animation for the placeholder when editing begins.
public
func
placeholderEditingDidBeginAnimation
()
{
placeholderLabel
.
textColor
=
placeholderTextColor
if
true
==
text
?
.
isEmpty
{
if
CGAffineTransformIsIdentity
(
placeholderLabel
.
transform
)
{
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
:
MTextField
=
self
{
s
.
placeholderLabel
.
transform
=
CGAffineTransformScale
(
s
.
placeholderLabel
.
transform
,
0.75
,
0.75
)
s
.
placeholderLabel
.
frame
=
CGRectMake
(
0
,
-
16
,
s
.
bounds
.
width
,
12
)
s
.
placeholderLabel
.
frame
.
origin
=
CGPointMake
(
0
,
-
16
)
}
})
}
...
...
@@ -326,14 +332,12 @@ public class MTextField : UITextField {
/// The animation for the placeholder when editing ends.
public
func
placeholderEditingDidEndAnimation
()
{
if
true
==
text
?
.
isEmpty
{
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
:
MTextField
=
self
{
s
.
placeholderLabel
.
transform
=
CGAffineTransformIdentity
s
.
placeholderLabel
.
frame
=
s
.
bounds
}
})
}
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
:
MTextField
=
self
{
s
.
placeholderLabel
.
transform
=
CGAffineTransformIdentity
s
.
placeholderLabel
.
frame
=
s
.
bounds
}
})
}
/// Prepares the divider.
...
...
@@ -345,13 +349,14 @@ public class MTextField : UITextField {
/// Prepares the placeholderLabel.
private
func
preparePlaceholderLabel
()
{
placeholderLabel
=
UILabel
()
placeholderLabel
=
UILabel
(
frame
:
CGRectZero
)
placeholderLabel
.
font
=
font
addSubview
(
placeholderLabel
)
}
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
=
UILabel
(
frame
:
CGRectZero
)
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
12
)
addSubview
(
detailLabel
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment