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
f22d7bdb
Commit
f22d7bdb
authored
Apr 13, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #302 from ramonvic/development
Fixed TextField Crash when dealoc itself
parents
bc0d00c7
71482c7e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
16 deletions
+96
-16
Examples/Storyboards/TextField/TextField.xcodeproj/project.pbxproj
+12
-0
Examples/Storyboards/TextField/TextField/Base.lproj/Main.storyboard
+0
-0
Examples/Storyboards/TextField/TextField/ViewController2.swift
+58
-0
Sources/iOS/TextField.swift
+26
-16
No files found.
Examples/Storyboards/TextField/TextField.xcodeproj/project.pbxproj
View file @
f22d7bdb
...
...
@@ -12,6 +12,9 @@
96D528071C8198AD00D3BDD1
/* Main.storyboard in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D528051C8198AD00D3BDD1
/* Main.storyboard */
;
};
96D528091C8198AD00D3BDD1
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D528081C8198AD00D3BDD1
/* Assets.xcassets */
;
};
96D5280C1C8198AD00D3BDD1
/* LaunchScreen.storyboard in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D5280A1C8198AD00D3BDD1
/* LaunchScreen.storyboard */
;
};
F602C1681CBDEEB8003DFE27
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F602C1671CBDEEB8003DFE27
/* Material.framework */
;
};
F602C1691CBDEEB8003DFE27
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F602C1671CBDEEB8003DFE27
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
F602C16B1CBDEEE4003DFE27
/* ViewController2.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F602C16A1CBDEEE4003DFE27
/* ViewController2.swift */
;
};
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
...
...
@@ -21,6 +24,7 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
F602C1691CBDEEB8003DFE27
/* Material.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -35,6 +39,9 @@
96D528081C8198AD00D3BDD1
/* Assets.xcassets */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
folder.assetcatalog
;
path
=
Assets.xcassets
;
sourceTree
=
"<group>"
;
};
96D5280B1C8198AD00D3BDD1
/* Base */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.storyboard
;
name
=
Base
;
path
=
Base.lproj/LaunchScreen.storyboard
;
sourceTree
=
"<group>"
;
};
96D5280D1C8198AD00D3BDD1
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
F602C1651CBDEE85003DFE27
/* Material.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"../../../build/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<group>"
;
};
F602C1671CBDEEB8003DFE27
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/ramon/Library/Developer/Xcode/DerivedData/Material-himrdtrjxqulxbgtyvxqqgkjdthx/Build/Products/Debug-iphonesimulator/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
F602C16A1CBDEEE4003DFE27
/* ViewController2.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController2.swift
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -42,6 +49,7 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
F602C1681CBDEEB8003DFE27
/* Material.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -51,6 +59,8 @@
96D527F51C8198AD00D3BDD1
=
{
isa
=
PBXGroup
;
children
=
(
F602C1671CBDEEB8003DFE27
/* Material.framework */
,
F602C1651CBDEE85003DFE27
/* Material.framework */
,
96D528001C8198AD00D3BDD1
/* TextField */
,
96D527FF1C8198AD00D3BDD1
/* Products */
,
);
...
...
@@ -73,6 +83,7 @@
96D528081C8198AD00D3BDD1
/* Assets.xcassets */
,
96D5280A1C8198AD00D3BDD1
/* LaunchScreen.storyboard */
,
96D5280D1C8198AD00D3BDD1
/* Info.plist */
,
F602C16A1CBDEEE4003DFE27
/* ViewController2.swift */
,
);
path
=
TextField
;
sourceTree
=
"<group>"
;
...
...
@@ -151,6 +162,7 @@
files
=
(
96D528041C8198AD00D3BDD1
/* ViewController.swift in Sources */
,
96D528021C8198AD00D3BDD1
/* AppDelegate.swift in Sources */
,
F602C16B1CBDEEE4003DFE27
/* ViewController2.swift in Sources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
Examples/Storyboards/TextField/TextField/Base.lproj/Main.storyboard
View file @
f22d7bdb
This diff is collapsed.
Click to expand it.
Examples/Storyboards/TextField/TextField/ViewController2.swift
0 → 100644
View file @
f22d7bdb
//
// ViewController2.swift
// TextField
//
// Created by Ramon Vicente on 4/13/16.
// Copyright © 2016 CosmicMind, Inc. All rights reserved.
//
import
UIKit
import
Material
class
ViewController2
:
UIViewController
,
TextFieldDelegate
{
@IBOutlet
weak
var
nameField
:
TextField
!
@IBOutlet
weak
var
emailField
:
TextField
!
@IBAction
func
close
(
sender
:
UIButton
)
{
dismissViewControllerAnimated
(
true
,
completion
:
nil
)
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
prepareNameField
()
prepareEmailField
()
}
/// General preparation statements.
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
white
}
/// Prepares the name TextField.
private
func
prepareNameField
()
{
nameField
.
placeholder
=
"First Name"
}
/// Prepares the email TextField.
private
func
prepareEmailField
()
{
emailField
.
delegate
=
self
emailField
.
placeholder
=
"Email"
/*
Used to display the error message, which is displayed when
the user presses the 'return' key.
*/
emailField
.
detailLabel
=
UILabel
()
emailField
.
detailLabel
!.
text
=
"Email is incorrect."
emailField
.
detailLabel
!.
font
=
RobotoFont
.
regularWithSize
(
12
)
emailField
.
detailLabelActiveColor
=
MaterialColor
.
red
.
accent3
// emailField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
}
/// Executed when the 'return' key is pressed when using the emailField.
func
textFieldShouldReturn
(
textField
:
UITextField
)
->
Bool
{
(
textField
as!
TextField
)
.
detailLabelHidden
=
0
==
textField
.
text
?
.
utf16
.
count
return
false
}
}
\ No newline at end of file
Sources/iOS/TextField.swift
View file @
f22d7bdb
...
...
@@ -631,22 +631,28 @@ public class TextField : UITextField {
titleLabel
.
frame
=
bounds
titleLabel
.
font
=
font
titleLabel
.
hidden
=
false
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
unowned
self
]
in
self
.
titleLabel
.
alpha
=
1
self
.
titleLabel
.
transform
=
CGAffineTransformScale
(
self
.
titleLabel
.
transform
,
0.75
,
0.75
)
self
.
titleLabel
.
frame
=
CGRectMake
(
0
,
-
(
self
.
titleLabelAnimationDistance
+
h
),
self
.
bounds
.
width
,
h
)
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
nil
!=
self
{
self
!.
titleLabel
.
alpha
=
1
self
!.
titleLabel
.
transform
=
CGAffineTransformScale
(
self
!.
titleLabel
.
transform
,
0.75
,
0.75
)
self
!.
titleLabel
.
frame
=
CGRectMake
(
0
,
-
(
self
!.
titleLabelAnimationDistance
+
h
),
self
!.
bounds
.
width
,
h
)
}
})
}
}
/// Hides and animates the titleLabel property.
private
func
hideTitleLabel
()
{
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
unowned
self
]
in
self
.
titleLabel
.
transform
=
CGAffineTransformIdentity
self
.
titleLabel
.
frame
=
self
.
bounds
})
{
[
unowned
self
]
_
in
self
.
placeholder
=
self
.
placeholderText
self
.
titleLabel
.
hidden
=
true
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
nil
!=
self
{
self
!.
titleLabel
.
transform
=
CGAffineTransformIdentity
self
!.
titleLabel
.
frame
=
self
!.
bounds
}
})
{
[
weak
self
]
_
in
if
nil
!=
self
{
self
!.
placeholder
=
self
!.
placeholderText
self
!.
titleLabel
.
hidden
=
true
}
}
}
...
...
@@ -657,9 +663,11 @@ public class TextField : UITextField {
let
h
:
CGFloat
=
ceil
(
v
.
font
.
lineHeight
)
v
.
frame
=
CGRectMake
(
0
,
bounds
.
height
+
lineLayerDistance
,
bounds
.
width
,
h
)
v
.
hidden
=
false
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
unowned
self
]
in
v
.
frame
.
origin
.
y
=
self
.
frame
.
height
+
self
.
lineLayerDistance
+
self
.
detailLabelAnimationDistance
v
.
alpha
=
1
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
nil
!=
self
{
v
.
frame
.
origin
.
y
=
self
!.
frame
.
height
+
self
!.
lineLayerDistance
+
self
!.
detailLabelAnimationDistance
v
.
alpha
=
1
}
})
}
}
...
...
@@ -668,9 +676,11 @@ public class TextField : UITextField {
/// Hides and animates the detailLabel property.
private
func
hideDetailLabel
()
{
if
let
v
:
UILabel
=
detailLabel
{
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
unowned
self
]
in
v
.
alpha
=
0
v
.
frame
.
origin
.
y
-=
self
.
detailLabelAnimationDistance
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
nil
!=
self
{
v
.
alpha
=
0
v
.
frame
.
origin
.
y
-=
self
!.
detailLabelAnimationDistance
}
})
{
_
in
v
.
hidden
=
true
}
...
...
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