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
2bfceb08
Commit
2bfceb08
authored
Dec 18, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prepare for release 1.24.4
parent
8d81d569
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
62 deletions
+61
-62
Examples/Programmatic/TextField/TextField.xcodeproj/project.pbxproj
+0
-6
Examples/Programmatic/TextField/TextField/ViewController.swift
+35
-18
README.md
+12
-2
Sources/TextField.swift
+14
-36
No files found.
Examples/Programmatic/TextField/TextField.xcodeproj/project.pbxproj
View file @
2bfceb08
...
...
@@ -11,8 +11,6 @@
966F57A31C226BAA009185B7
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966F57A21C226BAA009185B7
/* ViewController.swift */
;
};
966F57A81C226BAA009185B7
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966F57A71C226BAA009185B7
/* Assets.xcassets */
;
};
966F57AB1C226BAA009185B7
/* LaunchScreen.storyboard in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966F57A91C226BAA009185B7
/* LaunchScreen.storyboard */
;
};
966F57B31C226CA3009185B7
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966F57B21C226CA3009185B7
/* MaterialKit.framework */
;
};
966F57B41C226CA3009185B7
/* MaterialKit.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966F57B21C226CA3009185B7
/* MaterialKit.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
...
...
@@ -22,7 +20,6 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
966F57B41C226CA3009185B7
/* MaterialKit.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -36,7 +33,6 @@
966F57A71C226BAA009185B7
/* Assets.xcassets */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
folder.assetcatalog
;
path
=
Assets.xcassets
;
sourceTree
=
"<group>"
;
};
966F57AA1C226BAA009185B7
/* Base */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.storyboard
;
name
=
Base
;
path
=
Base.lproj/LaunchScreen.storyboard
;
sourceTree
=
"<group>"
;
};
966F57AC1C226BAA009185B7
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
966F57B21C226CA3009185B7
/* MaterialKit.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
MaterialKit.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-anypxbsecgdqqxevbavirvnffqxd/Build/Products/Debug-iphoneos/MaterialKit.framework"
;
sourceTree
=
"<absolute>"
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -44,7 +40,6 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
966F57B31C226CA3009185B7
/* MaterialKit.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -54,7 +49,6 @@
966F57941C226BAA009185B7
=
{
isa
=
PBXGroup
;
children
=
(
966F57B21C226CA3009185B7
/* MaterialKit.framework */
,
966F579F1C226BAA009185B7
/* TextField */
,
966F579E1C226BAA009185B7
/* Products */
,
);
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
2bfceb08
...
...
@@ -20,13 +20,15 @@ import UIKit
import
MaterialKit
class
ViewController
:
UIViewController
,
TextFieldDelegate
{
private
lazy
var
titleTextField
:
TextField
=
TextField
()
private
lazy
var
titleField
:
TextField
=
TextField
()
private
lazy
var
descriptionField
:
TextField
=
TextField
()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
prepareTitleTextField
()
prepareTitleField
()
prepareDescriptionField
()
}
/**
...
...
@@ -37,20 +39,37 @@ class ViewController: UIViewController, TextFieldDelegate {
}
/**
:name: prepareTitle
Text
Field
:description: A preparation helper
method for titleText
Field.
:name: prepareTitleField
:description: A preparation helper
for title
Field.
*/
private
func
prepareTitleTextField
()
{
titleTextField
.
frame
=
CGRectMake
(
100
,
100
,
200
,
35
)
titleTextField
.
placeholder
=
"Title"
titleTextField
.
textColor
=
MaterialColor
.
black
titleTextField
.
titleLabel
=
UILabel
()
titleTextField
.
titleLabel
!.
font
=
RobotoFont
.
boldWithSize
(
12
)
titleTextField
.
font
=
RobotoFont
.
boldWithSize
(
24
)
titleTextField
.
delegate
=
self
titleTextField
.
titleNormalColor
=
MaterialColor
.
grey
.
lighten1
titleTextField
.
titleHighlightedColor
=
MaterialColor
.
blue
.
accent3
view
.
addSubview
(
titleTextField
)
private
func
prepareTitleField
()
{
titleField
.
delegate
=
self
titleField
.
frame
=
CGRectMake
(
57
,
100
,
300
,
24
)
titleField
.
placeholder
=
"Title"
titleField
.
font
=
RobotoFont
.
regularWithSize
(
20
)
titleField
.
textColor
=
MaterialColor
.
black
titleField
.
titleLabel
=
UILabel
()
titleField
.
titleLabel
!.
font
=
RobotoFont
.
mediumWithSize
(
12
)
titleField
.
titleLabelNormalColor
=
MaterialColor
.
grey
.
lighten1
titleField
.
titleLabelHighlightedColor
=
MaterialColor
.
blue
.
accent3
view
.
addSubview
(
titleField
)
}
/**
:name: prepareDescriptionField
:description: A preparation helper for descriptionField.
*/
private
func
prepareDescriptionField
()
{
descriptionField
.
delegate
=
self
descriptionField
.
frame
=
CGRectMake
(
57
,
150
,
300
,
24
)
descriptionField
.
placeholder
=
"Description"
descriptionField
.
font
=
RobotoFont
.
regularWithSize
(
20
)
descriptionField
.
textColor
=
MaterialColor
.
black
descriptionField
.
titleLabel
=
UILabel
()
descriptionField
.
titleLabel
!.
font
=
RobotoFont
.
mediumWithSize
(
12
)
descriptionField
.
titleLabelNormalColor
=
MaterialColor
.
grey
.
lighten1
descriptionField
.
titleLabelHighlightedColor
=
MaterialColor
.
blue
.
accent3
view
.
addSubview
(
descriptionField
)
}
/**
...
...
@@ -59,9 +78,7 @@ class ViewController: UIViewController, TextFieldDelegate {
key on the keyboard.
*/
func
textFieldShouldReturn
(
textField
:
UITextField
)
->
Bool
{
if
textField
==
titleTextField
{
titleTextField
.
resignFirstResponder
()
}
textField
.
resignFirstResponder
()
return
false
}
...
...
README.md
View file @
2bfceb08
...
...
@@ -28,6 +28,7 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Table of Contents
*
[
TextView
](
#textview
)
*
[
MaterialColor
](
#materialcolor
)
*
[
MaterialLayer
](
#materiallayer
)
*
[
MaterialView
](
#materialview
)
...
...
@@ -43,14 +44,23 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Upcoming
*
Scrolling Techniques
*
TextField
*
SearchBarView
*
SearchBarViewController
*
TabView
*
TabViewController
*
TextView
*
Scrolling Techniques
*
More Examples
<a
name=
"textview"
/>
### TextField
A TextField is a great option to increase UX. Below is an example.
Space on mobile devices

<a
name=
"materialcolor"
/>
### MaterialColor
...
...
Sources/TextField.swift
View file @
2bfceb08
...
...
@@ -27,23 +27,18 @@ public class TextField : UITextField {
private
var
count
:
Int
?
/**
:name: titleNormalColor
:name: title
Label
NormalColor
*/
public
var
titleNormalColor
:
UIColor
?
{
public
var
title
Label
NormalColor
:
UIColor
?
{
didSet
{
titleLabel
?
.
textColor
=
titleNormalColor
titleLabel
?
.
textColor
=
title
Label
NormalColor
}
}
/**
:name: titleHighlightedColor
:name: title
Label
HighlightedColor
*/
public
var
titleHighlightedColor
:
UIColor
?
/**
:name: bottomBorderLayer
*/
public
private(set)
lazy
var
bottomBorderLayer
:
MaterialLayer
=
MaterialLayer
()
public
var
titleLabelHighlightedColor
:
UIColor
?
/**
:name: titleLabel
...
...
@@ -83,19 +78,10 @@ public class TextField : UITextField {
}
/**
:name: layoutSubviews
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
bottomBorderLayer
.
frame
=
CGRectMake
(
0
,
bounds
.
height
-
bottomBorderLayer
.
height
,
bounds
.
width
,
bottomBorderLayer
.
height
)
}
/**
:name: prepareView
*/
public
func
prepareView
()
{
clipsToBounds
=
false
prepareBottomBorderLayer
()
}
/**
...
...
@@ -103,7 +89,7 @@ public class TextField : UITextField {
*/
internal
func
textFieldDidBegin
(
textField
:
TextField
)
{
count
=
text
?
.
utf16
.
count
titleLabel
?
.
textColor
=
title
HighlightedColor
titleLabel
?
.
textColor
=
0
==
count
?
titleLabelNormalColor
:
titleLabel
HighlightedColor
}
/**
...
...
@@ -112,17 +98,18 @@ public class TextField : UITextField {
internal
func
textFieldDidChange
(
textField
:
TextField
)
{
if
0
==
count
&&
1
==
text
?
.
utf16
.
count
{
if
let
v
:
UILabel
=
titleLabel
{
v
.
hidden
=
false
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
v
.
hidden
=
false
v
.
alpha
=
1
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
})
titleLabel
?
.
textColor
=
titleLabelHighlightedColor
}
}
else
if
1
==
count
&&
0
==
text
?
.
utf16
.
count
{
if
let
v
:
UILabel
=
titleLabel
{
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
v
.
alpha
=
0
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
/
3
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
+
4
})
{
_
in
v
.
hidden
=
true
}
...
...
@@ -137,8 +124,8 @@ public class TextField : UITextField {
internal
func
textFieldDidEnd
(
textField
:
TextField
)
{
if
0
<
count
{
if
let
v
:
UILabel
=
titleLabel
{
v
.
hidden
=
false
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
v
.
hidden
=
false
v
.
alpha
=
1
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
})
...
...
@@ -147,22 +134,13 @@ public class TextField : UITextField {
if
let
v
:
UILabel
=
titleLabel
{
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
v
.
alpha
=
0
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
/
3
})
{
_
in
v
.
hidden
=
true
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
+
4
})
{
_
in
v
.
hidden
=
true
}
}
}
titleLabel
?
.
textColor
=
titleNormalColor
}
/**
:name: prepareBottomBorderLayer
*/
private
func
prepareBottomBorderLayer
()
{
bottomBorderLayer
.
frame
=
CGRectMake
(
0
,
bounds
.
height
+
5
,
bounds
.
width
,
3
)
bottomBorderLayer
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
.
CGColor
layer
.
addSublayer
(
bottomBorderLayer
)
titleLabel
?
.
textColor
=
titleLabelNormalColor
}
/**
...
...
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