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
f946055a
Commit
f946055a
authored
Apr 30, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed MTextField alignment issues when using resignFirstResponder
parent
ae240903
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
34 deletions
+14
-34
Examples/Programmatic/TextField/TextField/ViewController.swift
+1
-1
Sources/iOS/MTextField.swift
+13
-33
No files found.
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
f946055a
...
...
@@ -108,7 +108,7 @@ class ViewController: UIViewController, TextFieldDelegate {
private
func
prepareEmailField
()
{
emailField
=
MTextField
(
frame
:
CGRectMake
(
40
,
120
,
view
.
bounds
.
width
-
80
,
32
))
emailField
.
placeholder
=
"Email"
emailField
.
detail
=
"Error, incorrect email
.yyppggg
"
emailField
.
detail
=
"Error, incorrect email"
emailField
.
clearButtonMode
=
.
WhileEditing
emailField
.
delegate
=
self
...
...
Sources/iOS/MTextField.swift
View file @
f946055a
...
...
@@ -366,39 +366,8 @@ public class MTextField : UITextField {
/// Ensures that the components are sized correctly.
public
func
layoutToSize
()
{
if
!
animating
{
if
editing
{
switch
textAlignment
{
case
.
Left
,
.
Natural
:
placeholderLabel
.
frame
.
origin
.
x
=
0
detailLabel
.
frame
.
origin
.
x
=
0
case
.
Right
:
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
detailLabel
.
frame
.
origin
.
x
=
placeholderLabel
.
frame
.
origin
.
x
case
.
Center
:
placeholderLabel
.
center
.
x
=
width
/
2
detailLabel
.
center
.
x
=
placeholderLabel
.
center
.
x
default
:
break
}
placeholderLabel
.
frame
.
size
.
width
=
width
*
0.75
detailLabel
.
frame
.
size
.
width
=
placeholderLabel
.
frame
.
width
}
else
{
layoutPlaceholderLabel
()
layoutDetailLabel
()
switch
textAlignment
{
case
.
Left
,
.
Natural
:
placeholderLabel
.
frame
.
origin
.
x
=
0
detailLabel
.
frame
.
origin
.
x
=
0
case
.
Right
:
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
detailLabel
.
frame
.
origin
.
x
=
placeholderLabel
.
frame
.
origin
.
x
case
.
Center
:
placeholderLabel
.
center
.
x
=
width
/
2
detailLabel
.
center
.
x
=
placeholderLabel
.
center
.
x
default
:
break
}
placeholderLabel
.
frame
.
size
.
width
=
true
==
text
?
.
isEmpty
?
width
:
width
*
0.75
detailLabel
.
frame
.
size
.
width
=
placeholderLabel
.
frame
.
width
}
}
}
...
...
@@ -409,7 +378,7 @@ public class MTextField : UITextField {
/// Layout the placeholderLabel.
public
func
layoutPlaceholderLabel
()
{
if
true
==
text
?
.
isEmpty
{
if
!
editing
&&
true
==
text
?
.
isEmpty
{
placeholderLabel
.
frame
=
bounds
}
else
if
CGAffineTransformIsIdentity
(
placeholderLabel
.
transform
)
{
placeholderLabel
.
frame
=
bounds
...
...
@@ -423,13 +392,24 @@ public class MTextField : UITextField {
}
placeholderLabel
.
frame
.
origin
.
y
=
-
placeholderLabel
.
frame
.
size
.
height
placeholderLabel
.
textColor
=
placeholderColor
}
else
{
switch
textAlignment
{
case
.
Left
,
.
Natural
:
placeholderLabel
.
frame
.
origin
.
x
=
0
case
.
Right
:
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
case
.
Center
:
placeholderLabel
.
center
.
x
=
width
/
2
default
:
break
}
placeholderLabel
.
frame
.
size
.
width
=
width
*
0.75
}
}
/// Layout the detailLabel.
public
func
layoutDetailLabel
()
{
var
h
:
CGFloat
=
nil
==
detail
?
12
:
detailLabel
.
font
.
stringSize
(
detail
!
,
constrainedToWidth
:
Double
(
width
))
.
height
detailLabel
.
frame
=
CGRectMake
(
0
,
height
+
8
,
width
,
h
)
detailLabel
.
frame
=
CGRectMake
(
0
,
divider
.
frame
.
origin
.
y
+
8
,
width
,
h
)
}
/// The animation for the divider when editing begins.
...
...
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