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
87baa186
Commit
87baa186
authored
Sep 05, 2017
by
Daniel Dahan
Committed by
GitHub
Sep 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #715 from mjgaylord/development
Uppercase placeholder in TextField when active
parents
9dc1261d
eb9f06fa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
Sources/iOS/TextField.swift
+23
-3
No files found.
Sources/iOS/TextField.swift
View file @
87baa186
...
...
@@ -184,7 +184,11 @@ open class TextField: UITextField {
return
placeholderLabel
.
text
}
set
(
value
)
{
if
isEditing
&&
isPlaceholderUppercasedWhenEditing
{
placeholderLabel
.
text
=
value
?
.
uppercased
()
}
else
{
placeholderLabel
.
text
=
value
}
layoutSubviews
()
}
}
...
...
@@ -353,7 +357,6 @@ open class TextField: UITextField {
open
var
isVisibilityIconButtonAutoHandled
=
true
{
didSet
{
visibilityIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
:
.
touchUpInside
)
guard
isVisibilityIconButtonAutoHandled
else
{
return
}
...
...
@@ -362,6 +365,13 @@ open class TextField: UITextField {
}
}
@IBInspectable
open
var
isPlaceholderUppercasedWhenEditing
:
Bool
=
false
{
didSet
{
placeholder
=
placeholder
?
.
uppercased
()
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
...
...
@@ -638,10 +648,16 @@ extension TextField {
updatePlaceholderLabelColor
()
guard
isPlaceholderAnimated
else
{
if
isPlaceholderUppercasedWhenEditing
{
placeholderLabel
.
text
=
placeholderLabel
.
text
?
.
uppercased
()
}
return
}
guard
isEmpty
else
{
if
isPlaceholderUppercasedWhenEditing
{
placeholderLabel
.
text
=
placeholderLabel
.
text
?
.
uppercased
()
}
return
}
...
...
@@ -651,6 +667,9 @@ extension TextField {
}
s
.
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
s
.
placeholderActiveScale
,
y
:
s
.
placeholderActiveScale
)
if
self
?
.
isPlaceholderUppercasedWhenEditing
??
false
{
s
.
placeholderLabel
.
text
=
s
.
placeholderLabel
.
text
?
.
uppercased
()
}
switch
s
.
textAlignment
{
case
.
left
,
.
natural
:
...
...
@@ -672,11 +691,12 @@ extension TextField {
}
updatePlaceholderLabelColor
()
if
self
.
isPlaceholderUppercasedWhenEditing
{
placeholderLabel
.
text
=
placeholderLabel
.
text
?
.
capitalized
}
guard
isPlaceholderAnimated
else
{
return
}
guard
isEmpty
else
{
return
}
...
...
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