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
01fe9110
Commit
01fe9110
authored
May 12, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working NavigationBar
parent
2e247729
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
142 additions
and
191 deletions
+142
-191
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
+6
-6
Examples/Programmatic/App/App/ItemViewController.swift
+10
-10
Examples/Programmatic/App/App/RecipesViewController.swift
+1
-2
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
+0
-5
Examples/Programmatic/CardView/CardView/ViewController.swift
+0
-6
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
+0
-2
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
+0
-1
Examples/Programmatic/MaterialDepth/MaterialDepth/ViewController.swift
+0
-5
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
+0
-1
Examples/Programmatic/MaterialLayout/MaterialLayout/ViewController.swift
+0
-8
Examples/Programmatic/MaterialSwitch/MaterialSwitch/ViewController.swift
+0
-8
Examples/Programmatic/Menu/Menu/ViewController.swift
+0
-1
Examples/Programmatic/MenuView/MenuView/ViewController.swift
+0
-2
Examples/Programmatic/MenuViewController/MenuViewController/AppMenuViewController.swift
+0
-1
Examples/Programmatic/SideNavigationController/SideNavigationController/AppLeftViewController.swift
+0
-1
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
+0
-2
Examples/Programmatic/TextField/TextField/ViewController.swift
+0
-5
Examples/Programmatic/TextView/TextView/ViewController.swift
+0
-1
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
+0
-1
Sources/iOS/MaterialLayout.swift
+22
-67
Sources/iOS/NavigationBar.swift
+85
-53
Sources/iOS/NavigationItem.swift
+17
-2
Sources/iOS/StatusBarView.swift
+1
-1
No files found.
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
View file @
01fe9110
...
...
@@ -9,8 +9,6 @@
/* Begin PBXBuildFile section */
96162C6C1CA71C8700E3A235
/* VideoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
;
};
96162C6E1CA7274E00E3A235
/* PhotoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
;
};
961F19321CE2579D008927C5
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F19311CE2579D008927C5
/* Material.framework */
;
};
961F19331CE2579D008927C5
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F19311CE2579D008927C5
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
9663F9341C7A744600AF0965
/* RecommendationViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9331C7A744600AF0965
/* RecommendationViewController.swift */
;
};
9663F9391C7A744600AF0965
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9381C7A744600AF0965
/* Assets.xcassets */
;
};
...
...
@@ -20,6 +18,8 @@
9663F94C1C7A74C700AF0965
/* AppMenuViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F94B1C7A74C700AF0965
/* AppMenuViewController.swift */
;
};
9663F94E1C7A74EA00AF0965
/* AppLeftViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F94D1C7A74EA00AF0965
/* AppLeftViewController.swift */
;
};
9663F9521C7A751D00AF0965
/* ItemViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9511C7A751D00AF0965
/* ItemViewController.swift */
;
};
9692C91F1CE4303F008C2766
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9692C91E1CE4303F008C2766
/* Material.framework */
;
};
9692C9201CE4303F008C2766
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9692C91E1CE4303F008C2766
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96CC08881C7FEBD60034FF84
/* RecipesViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96CC08871C7FEBD60034FF84
/* RecipesViewController.swift */
;
};
/* End PBXBuildFile section */
...
...
@@ -30,7 +30,7 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
96
1F19331CE2579D008927C5
/* Material.framework in Embed Frameworks */
,
96
92C9201CE4303F008C2766
/* Material.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -40,7 +40,6 @@
/* Begin PBXFileReference section */
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
VideoViewController.swift
;
sourceTree
=
"<group>"
;
};
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoViewController.swift
;
sourceTree
=
"<group>"
;
};
961F19311CE2579D008927C5
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/CosmicMind-hgvxkqfizbxkrsfcxbtlafgqkbve/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
9663F92E1C7A744600AF0965
/* App.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
App.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
9663F9311C7A744600AF0965
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
9663F9331C7A744600AF0965
/* RecommendationViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RecommendationViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -52,6 +51,7 @@
9663F94B1C7A74C700AF0965
/* AppMenuViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppMenuViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F94D1C7A74EA00AF0965
/* AppLeftViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppLeftViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F9511C7A751D00AF0965
/* ItemViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ItemViewController.swift
;
sourceTree
=
"<group>"
;
};
9692C91E1CE4303F008C2766
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/CosmicMind-hgvxkqfizbxkrsfcxbtlafgqkbve/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96CC08871C7FEBD60034FF84
/* RecipesViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RecipesViewController.swift
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
...
...
@@ -60,7 +60,7 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
96
1F19321CE2579D008927C5
/* Material.framework in Frameworks */
,
96
92C91F1CE4303F008C2766
/* Material.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -70,7 +70,7 @@
9663F9251C7A744500AF0965
=
{
isa
=
PBXGroup
;
children
=
(
96
1F19311CE2579D008927C5
/* Material.framework */
,
96
92C91E1CE4303F008C2766
/* Material.framework */
,
9663F9301C7A744600AF0965
/* App */
,
9663F92F1C7A744600AF0965
/* Products */
,
);
...
...
Examples/Programmatic/App/App/ItemViewController.swift
View file @
01fe9110
...
...
@@ -111,11 +111,11 @@ class ItemViewController: UIViewController {
/// Prepares the navigationItem.
private
func
prepareNavigationItem
()
{
navigationItem
.
title
=
"Item
"
navigationItem
.
title
Label
.
text
=
"Itempppyyggg
"
navigationItem
.
titleLabel
.
textAlignment
=
.
Left
navigationItem
.
titleLabel
.
textColor
=
MaterialColor
.
white
navigationItem
.
detail
=
"January 22
, 2016"
navigationItem
.
detail
Label
.
text
=
"January 22pppyyyggg
, 2016"
navigationItem
.
detailLabel
.
textAlignment
=
.
Left
navigationItem
.
detailLabel
.
textColor
=
MaterialColor
.
white
...
...
@@ -141,11 +141,11 @@ class ItemViewController: UIViewController {
imageCardView
.
cornerRadiusPreset
=
.
None
imageCardView
.
maxImageHeight
=
300
imageCardView
.
titleLabel
=
UILabel
()
imageCardView
.
titleLabel
?
.
text
=
data
[
"title"
]
as?
String
imageCardView
.
titleLabel
?
.
textColor
=
MaterialColor
.
grey
.
darken4
imageCardView
.
titleLabel
?
.
font
=
RobotoFont
.
regularWithSize
(
20
)
//
imageCardView.titleLabel = UILabel()
//
imageCardView.titleLabel?.text = data["title"] as? String
//
imageCardView.titleLabel?.textColor = MaterialColor.grey.darken4
//
imageCardView.titleLabel?.font = RobotoFont.regularWithSize(20)
//
let
detailLabel
:
UILabel
=
UILabel
()
detailLabel
.
text
=
data
[
"detail"
]
as?
String
detailLabel
.
textColor
=
MaterialColor
.
grey
.
darken2
...
...
@@ -154,9 +154,9 @@ class ItemViewController: UIViewController {
imageCardView
.
contentView
=
detailLabel
imageCardView
.
contentViewInset
.
top
=
52
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
imageCardView
.
image
=
image
//
//
let image: UIImage? = UIImage(named: data["image"] as! String)
//
imageCardView.image = image
scrollView
.
addSubview
(
imageCardView
)
}
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
01fe9110
...
...
@@ -244,8 +244,7 @@ class RecipesViewController: UIViewController {
/// Prepares the navigationItem.
private
func
prepareNavigationItem
()
{
navigationItem
.
title
=
"Recipes"
navigationItem
.
titleLabel
.
textAlignment
=
.
Left
navigationItem
.
titleLabel
.
text
=
"Recipesqqggyy"
navigationItem
.
titleLabel
.
textColor
=
MaterialColor
.
white
navigationItem
.
leftControls
=
[
menuButton
]
...
...
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
View file @
01fe9110
...
...
@@ -224,7 +224,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
view
.
addSubview
(
captureView
)
captureView
.
tapToFocusEnabled
=
true
captureView
.
tapToExposeEnabled
=
true
captureView
.
translatesAutoresizingMaskIntoConstraints
=
false
captureView
.
delegate
=
self
captureView
.
captureSession
.
delegate
=
self
MaterialLayout
.
alignToParent
(
view
,
child
:
captureView
)
...
...
@@ -283,7 +282,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
let
img4
:
UIImage
?
=
UIImage
(
named
:
"ic_photo_camera_white_36pt"
)
cameraButton
.
width
=
72
cameraButton
.
height
=
72
cameraButton
.
pulseColor
=
nil
cameraButton
.
setImage
(
img4
,
forState
:
.
Normal
)
cameraButton
.
setImage
(
img4
,
forState
:
.
Highlighted
)
...
...
@@ -297,7 +295,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
let
img5
:
UIImage
?
=
UIImage
(
named
:
"ic_videocam_white_36pt"
)
videoButton
.
width
=
72
videoButton
.
height
=
72
videoButton
.
pulseColor
=
nil
videoButton
.
setImage
(
img5
,
forState
:
.
Normal
)
videoButton
.
setImage
(
img5
,
forState
:
.
Highlighted
)
...
...
@@ -309,7 +306,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
*/
private
func
prepareSwitchCamerasButton
()
{
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_camera_front_white"
)
switchCamerasButton
.
pulseColor
=
nil
switchCamerasButton
.
setImage
(
img
,
forState
:
.
Normal
)
switchCamerasButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
...
...
@@ -321,7 +317,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
*/
private
func
prepareFlashButton
()
{
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)
flashButton
.
pulseColor
=
nil
flashButton
.
setImage
(
img
,
forState
:
.
Normal
)
flashButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
...
...
Examples/Programmatic/CardView/CardView/ViewController.swift
View file @
01fe9110
...
...
@@ -80,7 +80,6 @@ class ViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
cardView
)
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
...
...
@@ -89,7 +88,6 @@ class ViewController: UIViewController {
let
cardView
:
CardView
=
CardView
()
cardView
.
divider
=
false
cardView
.
backgroundColor
=
MaterialColor
.
red
.
base
cardView
.
pulseColor
=
nil
cardView
.
image
=
UIImage
(
named
:
"Material-iTunesArtWork"
)?
.
resize
(
toHeight
:
75
)
cardView
.
contentsGravityPreset
=
.
BottomRight
...
...
@@ -121,7 +119,6 @@ class ViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
cardView
)
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
...
...
@@ -162,7 +159,6 @@ class ViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
cardView
)
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
...
...
@@ -170,7 +166,6 @@ class ViewController: UIViewController {
private
func
prepareCardViewButtonBarExample
()
{
let
cardView
:
CardView
=
CardView
()
cardView
.
divider
=
false
cardView
.
pulseColor
=
nil
cardView
.
backgroundColor
=
MaterialColor
.
blueGrey
.
darken4
// Search button.
...
...
@@ -203,7 +198,6 @@ class ViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
cardView
)
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
...
...
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
View file @
01fe9110
...
...
@@ -84,7 +84,6 @@ class ViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
imageCardView
)
imageCardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
imageCardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
imageCardView
,
left
:
20
,
right
:
20
)
}
...
...
@@ -134,7 +133,6 @@ class ViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
imageCardView
)
imageCardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
imageCardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
imageCardView
,
left
:
20
,
right
:
20
)
}
...
...
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
View file @
01fe9110
...
...
@@ -87,7 +87,6 @@ class ViewController: UIViewController {
// Use MaterialLayout to easily align the tableView.
view
.
addSubview
(
collectionView
)
collectionView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
view
,
child
:
collectionView
)
}
}
...
...
Examples/Programmatic/MaterialDepth/MaterialDepth/ViewController.swift
View file @
01fe9110
...
...
@@ -46,27 +46,22 @@ class ViewController: UIViewController {
/// Prepares the MaterialDepth.
private
func
prepareMaterialDepth
()
{
let
v1
:
MaterialView
=
MaterialView
()
v1
.
translatesAutoresizingMaskIntoConstraints
=
false
v1
.
depth
=
.
Depth1
view
.
addSubview
(
v1
)
let
v2
:
MaterialView
=
MaterialView
()
v2
.
translatesAutoresizingMaskIntoConstraints
=
false
v2
.
depth
=
.
Depth2
view
.
addSubview
(
v2
)
let
v3
:
MaterialView
=
MaterialView
()
v3
.
translatesAutoresizingMaskIntoConstraints
=
false
v3
.
depth
=
.
Depth3
view
.
addSubview
(
v3
)
let
v4
:
MaterialView
=
MaterialView
()
v4
.
translatesAutoresizingMaskIntoConstraints
=
false
v4
.
depth
=
.
Depth4
view
.
addSubview
(
v4
)
let
v5
:
MaterialView
=
MaterialView
()
v5
.
translatesAutoresizingMaskIntoConstraints
=
false
v5
.
depth
=
.
Depth5
view
.
addSubview
(
v5
)
...
...
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
View file @
01fe9110
...
...
@@ -109,7 +109,6 @@ class ViewController: UIViewController {
tableView
.
registerClass
(
MaterialTableViewCell
.
self
,
forCellReuseIdentifier
:
"Cell"
)
tableView
.
dataSource
=
self
tableView
.
delegate
=
self
tableView
.
translatesAutoresizingMaskIntoConstraints
=
false
view
.
addSubview
(
tableView
)
...
...
Examples/Programmatic/MaterialLayout/MaterialLayout/ViewController.swift
View file @
01fe9110
...
...
@@ -53,28 +53,24 @@ class ViewController: UIViewController {
/// Layout views horizontally with equal width.
private
func
prepareAlignToParentHorizontallyExample
()
{
let
label1
:
UILabel
=
UILabel
()
label1
.
translatesAutoresizingMaskIntoConstraints
=
false
label1
.
backgroundColor
=
MaterialColor
.
red
.
base
label1
.
text
=
"A"
label1
.
textAlignment
=
.
Center
view
.
addSubview
(
label1
)
let
label2
:
UILabel
=
UILabel
()
label2
.
translatesAutoresizingMaskIntoConstraints
=
false
label2
.
backgroundColor
=
MaterialColor
.
green
.
base
label2
.
text
=
"B"
label2
.
textAlignment
=
.
Center
view
.
addSubview
(
label2
)
let
label3
:
UILabel
=
UILabel
()
label3
.
translatesAutoresizingMaskIntoConstraints
=
false
label3
.
backgroundColor
=
MaterialColor
.
blue
.
base
label3
.
text
=
"C"
label3
.
textAlignment
=
.
Center
view
.
addSubview
(
label3
)
let
label4
:
UILabel
=
UILabel
()
label4
.
translatesAutoresizingMaskIntoConstraints
=
false
label4
.
backgroundColor
=
MaterialColor
.
yellow
.
base
label4
.
text
=
"D"
label4
.
textAlignment
=
.
Center
...
...
@@ -103,28 +99,24 @@ class ViewController: UIViewController {
/// Layout views vertically with equal height.
private
func
prepareAlignToParentVerticallyExample
()
{
let
label1
:
UILabel
=
UILabel
()
label1
.
translatesAutoresizingMaskIntoConstraints
=
false
label1
.
backgroundColor
=
MaterialColor
.
red
.
base
label1
.
text
=
"A"
label1
.
textAlignment
=
.
Center
view
.
addSubview
(
label1
)
let
label2
:
UILabel
=
UILabel
()
label2
.
translatesAutoresizingMaskIntoConstraints
=
false
label2
.
backgroundColor
=
MaterialColor
.
green
.
base
label2
.
text
=
"B"
label2
.
textAlignment
=
.
Center
view
.
addSubview
(
label2
)
let
label3
:
UILabel
=
UILabel
()
label3
.
translatesAutoresizingMaskIntoConstraints
=
false
label3
.
backgroundColor
=
MaterialColor
.
blue
.
base
label3
.
text
=
"C"
label3
.
textAlignment
=
.
Center
view
.
addSubview
(
label3
)
let
label4
:
UILabel
=
UILabel
()
label4
.
translatesAutoresizingMaskIntoConstraints
=
false
label4
.
backgroundColor
=
MaterialColor
.
yellow
.
base
label4
.
text
=
"D"
label4
.
textAlignment
=
.
Center
...
...
Examples/Programmatic/MaterialSwitch/MaterialSwitch/ViewController.swift
View file @
01fe9110
...
...
@@ -51,10 +51,8 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
view
.
backgroundColor
=
MaterialColor
.
white
view
.
addSubview
(
topView
)
topView
.
translatesAutoresizingMaskIntoConstraints
=
false
view
.
addSubview
(
bottomView
)
bottomView
.
translatesAutoresizingMaskIntoConstraints
=
false
bottomView
.
backgroundColor
=
MaterialColor
.
grey
.
darken4
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
topView
)
...
...
@@ -66,18 +64,15 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
private
func
prepareLightContentMaterialSwitch
()
{
let
c1
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Small
)
c1
.
delegate
=
self
c1
.
translatesAutoresizingMaskIntoConstraints
=
false
topView
.
addSubview
(
c1
)
let
c2
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
On
,
style
:
.
LightContent
)
c2
.
delegate
=
self
c2
.
translatesAutoresizingMaskIntoConstraints
=
false
topView
.
addSubview
(
c2
)
let
c3
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Large
)
c3
.
delegate
=
self
c3
.
enabled
=
false
c3
.
translatesAutoresizingMaskIntoConstraints
=
false
topView
.
addSubview
(
c3
)
MaterialLayout
.
alignToParentHorizontally
(
topView
,
child
:
c1
)
...
...
@@ -90,18 +85,15 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
private
func
prepareDefaultMaterialSwitch
()
{
let
c1
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
Default
,
size
:
.
Small
)
c1
.
delegate
=
self
c1
.
translatesAutoresizingMaskIntoConstraints
=
false
bottomView
.
addSubview
(
c1
)
let
c2
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
On
)
c2
.
delegate
=
self
c2
.
translatesAutoresizingMaskIntoConstraints
=
false
bottomView
.
addSubview
(
c2
)
let
c3
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
Default
,
size
:
.
Large
)
c3
.
delegate
=
self
c3
.
enabled
=
false
c3
.
translatesAutoresizingMaskIntoConstraints
=
false
bottomView
.
addSubview
(
c3
)
MaterialLayout
.
alignToParentHorizontally
(
bottomView
,
child
:
c1
)
...
...
Examples/Programmatic/Menu/Menu/ViewController.swift
View file @
01fe9110
...
...
@@ -128,7 +128,6 @@ class ViewController: UIViewController {
private
func
prepareFabMenuExample
()
{
var
image
:
UIImage
?
=
UIImage
(
named
:
"ic_add_white"
)
let
btn1
:
FabButton
=
FabButton
()
btn1
.
pulseColor
=
nil
btn1
.
setImage
(
image
,
forState
:
.
Normal
)
btn1
.
setImage
(
image
,
forState
:
.
Highlighted
)
btn1
.
addTarget
(
self
,
action
:
#selector(
handleFabMenu
)
,
forControlEvents
:
.
TouchUpInside
)
...
...
Examples/Programmatic/MenuView/MenuView/ViewController.swift
View file @
01fe9110
...
...
@@ -85,7 +85,6 @@ class ViewController: UIViewController {
let
btn1
:
FabButton
=
FabButton
()
btn1
.
depth
=
.
None
btn1
.
tintColor
=
MaterialColor
.
blue
.
accent3
btn1
.
pulseColor
=
nil
btn1
.
borderColor
=
MaterialColor
.
blue
.
accent3
btn1
.
backgroundColor
=
MaterialColor
.
white
btn1
.
borderWidth
=
1
...
...
@@ -139,7 +138,6 @@ class ViewController: UIViewController {
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
view
.
addSubview
(
menuView
)
menuView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
size
(
view
,
child
:
menuView
,
width
:
diameter
,
height
:
diameter
)
MaterialLayout
.
alignFromBottomLeft
(
view
,
child
:
menuView
,
bottom
:
16
,
left
:
(
view
.
bounds
.
width
-
diameter
)
/
2
)
}
...
...
Examples/Programmatic/MenuViewController/MenuViewController/AppMenuViewController.swift
View file @
01fe9110
...
...
@@ -136,7 +136,6 @@ class AppMenuViewController: MenuViewController {
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
view
.
addSubview
(
menuView
)
menuView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
size
(
view
,
child
:
menuView
,
width
:
baseViewSize
.
width
,
height
:
baseViewSize
.
height
)
MaterialLayout
.
alignFromBottomRight
(
view
,
child
:
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
}
...
...
Examples/Programmatic/SideNavigationController/SideNavigationController/AppLeftViewController.swift
View file @
01fe9110
...
...
@@ -76,7 +76,6 @@ class AppLeftViewController: UIViewController {
// Use MaterialLayout to easily align the tableView.
view
.
addSubview
(
tableView
)
tableView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
view
,
child
:
tableView
)
}
}
...
...
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
View file @
01fe9110
...
...
@@ -84,7 +84,6 @@ class ViewController: UIViewController {
/// Prepares the CardView.
func
prepareCardView
()
{
let
cardView
:
CardView
=
CardView
()
cardView
.
pulseColor
=
nil
cardView
.
backgroundColor
=
MaterialColor
.
grey
.
lighten5
cardView
.
cornerRadiusPreset
=
.
Radius1
cardView
.
divider
=
false
...
...
@@ -117,7 +116,6 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
closeButton
]
cardView
.
rightButtons
=
[
settingButton
]
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
view
.
addSubview
(
cardView
)
MaterialLayout
.
alignToParent
(
view
,
child
:
cardView
,
left
:
10
,
right
:
10
,
top
:
100
,
bottom
:
100
)
}
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
01fe9110
...
...
@@ -65,7 +65,6 @@ class ViewController: UIViewController, TextFieldDelegate {
/// Prepares the resign responder button.
private
func
prepareResignResponderButton
()
{
let
btn
:
RaisedButton
=
RaisedButton
()
btn
.
translatesAutoresizingMaskIntoConstraints
=
false
btn
.
addTarget
(
self
,
action
:
#selector(
handleResignResponderButton
)
,
forControlEvents
:
.
TouchUpInside
)
btn
.
setTitle
(
"Resign"
,
forState
:
.
Normal
)
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Normal
)
...
...
@@ -93,8 +92,6 @@ class ViewController: UIViewController, TextFieldDelegate {
nameField
.
textAlignment
=
.
Center
nameField
.
clearButtonMode
=
.
WhileEditing
// The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly.
nameField
.
translatesAutoresizingMaskIntoConstraints
=
false
view
.
addSubview
(
nameField
)
// Size the TextField to the maximum width, less 40 pixels on either side
...
...
@@ -129,8 +126,6 @@ class ViewController: UIViewController, TextFieldDelegate {
// Setting the visibilityFlatButton color.
passwordField
.
visibilityIconButton
?
.
tintColor
=
MaterialColor
.
green
.
base
.
colorWithAlphaComponent
(
passwordField
.
secureTextEntry
?
0.38
:
0.54
)
// The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly.
passwordField
.
translatesAutoresizingMaskIntoConstraints
=
false
view
.
addSubview
(
passwordField
)
// Size the TextField to the maximum width, less 40 pixels on either side
...
...
Examples/Programmatic/TextView/TextView/ViewController.swift
View file @
01fe9110
...
...
@@ -76,7 +76,6 @@ class ViewController: UIViewController, TextDelegate {
textView
.
titleLabelActiveColor
=
MaterialColor
.
blue
.
accent3
view
.
addSubview
(
textView
)
textView
!.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
view
,
child
:
textView
!
,
top
:
124
,
left
:
24
,
bottom
:
24
,
right
:
24
)
}
...
...
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
View file @
01fe9110
...
...
@@ -44,7 +44,6 @@ class RootViewController: UIViewController {
fabButton
.
addTarget
(
self
,
action
:
#selector(
handleFabButton
)
,
forControlEvents
:
.
TouchUpInside
)
view
.
addSubview
(
fabButton
)
fabButton
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromBottomRight
(
view
,
child
:
fabButton
,
bottom
:
16
,
right
:
16
)
MaterialLayout
.
size
(
view
,
child
:
fabButton
,
width
:
64
,
height
:
64
)
}
...
...
Sources/iOS/MaterialLayout.swift
View file @
01fe9110
...
...
@@ -31,38 +31,27 @@
import
UIKit
public
struct
MaterialLayout
{
/**
:name: width
*/
/// Width
public
static
func
width
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"width"
:
width
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"H:[child(width)]"
,
options
:
options
,
metrics
:
metrics
,
views
:
views
))
}
/**
:name: height
*/
/// Height
public
static
func
height
(
parent
:
UIView
,
child
:
UIView
,
height
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"height"
:
height
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"V:[child(height)]"
,
options
:
options
,
metrics
:
metrics
,
views
:
views
))
}
/**
:name: size
*/
/// Size
public
static
func
size
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
,
height
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
width
(
parent
,
child
:
child
,
width
:
width
)
MaterialLayout
.
height
(
parent
,
child
:
child
,
height
:
height
)
}
/**
:name: alignToParentHorizontally
*/
/// AlignToParentHorizontally
public
static
func
alignToParentHorizontally
(
parent
:
UIView
,
children
:
Array
<
UIView
>
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
spacing
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
if
0
<
children
.
count
{
var
format
:
String
=
"H:|-(left)-"
...
...
@@ -73,15 +62,12 @@ public struct MaterialLayout {
i
+=
1
views
[
k
]
=
v
format
+=
i
>
children
.
count
?
"[
\(
k
)
(==view1)]-(right)-|"
:
"[
\(
k
)
(==view1)]-(spacing)-"
v
.
translatesAutoresizingMaskIntoConstraints
=
false
}
parent
.
addConstraints
(
constraint
(
format
,
options
:
options
,
metrics
:
[
"left"
:
left
,
"right"
:
right
,
"spacing"
:
spacing
],
views
:
views
))
}
}
/**
:name: alignToParentVertically
*/
/// AlignToParentVertically
public
static
func
alignToParentVertically
(
parent
:
UIView
,
children
:
Array
<
UIView
>
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
spacing
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
if
0
<
children
.
count
{
var
format
:
String
=
"V:|-(top)-"
...
...
@@ -92,109 +78,78 @@ public struct MaterialLayout {
i
+=
1
views
[
k
]
=
v
format
+=
i
>
children
.
count
?
"[
\(
k
)
(==view1)]-(bottom)-|"
:
"[
\(
k
)
(==view1)]-(spacing)-"
v
.
translatesAutoresizingMaskIntoConstraints
=
false
}
parent
.
addConstraints
(
constraint
(
format
,
options
:
options
,
metrics
:
[
"top"
:
top
,
"bottom"
:
bottom
,
"spacing"
:
spacing
],
views
:
views
))
}
}
/**
:name: alignToParentHorizontally
*/
/// AlignToParentHorizontally
public
static
func
alignToParentHorizontally
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]-(right)-|"
,
options
:
options
,
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignToParentVertically
*/
/// AlignToParentVertically
public
static
func
alignToParentVertically
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
options
,
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignToParent
*/
/// AlignToParent
public
static
func
alignToParent
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
alignToParentHorizontally
(
parent
,
child
:
child
,
left
:
left
,
right
:
right
)
alignToParentVertically
(
parent
,
child
:
child
,
top
:
top
,
bottom
:
bottom
)
}
/**
:name: alignFromTopLeft
*/
/// AlignFromTopLeft
public
static
func
alignFromTopLeft
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
alignFromTop
(
parent
,
child
:
child
,
top
:
top
)
alignFromLeft
(
parent
,
child
:
child
,
left
:
left
)
}
/**
:name: alignFromTopRight
*/
/// AlignFromTopRight
public
static
func
alignFromTopRight
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
alignFromTop
(
parent
,
child
:
child
,
top
:
top
)
alignFromRight
(
parent
,
child
:
child
,
right
:
right
)
}
/**
:name: alignFromBottomLeft
*/
/// AlignFromBottomLeft
public
static
func
alignFromBottomLeft
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
alignFromBottom
(
parent
,
child
:
child
,
bottom
:
bottom
)
alignFromLeft
(
parent
,
child
:
child
,
left
:
left
)
}
/**
:name: alignFromBottomRight
*/
/// AlignFromBottomRight
public
static
func
alignFromBottomRight
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
alignFromBottom
(
parent
,
child
:
child
,
bottom
:
bottom
)
alignFromRight
(
parent
,
child
:
child
,
right
:
right
)
}
/**
:name: alignFromTop
*/
/// AlignFromTop
public
static
func
alignFromTop
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]"
,
options
:
options
,
metrics
:
[
"top"
:
top
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignFromLeft
*/
/// AlignFromLeft
public
static
func
alignFromLeft
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]"
,
options
:
options
,
metrics
:
[
"left"
:
left
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignFromBottom
*/
/// AlignFromBottom
public
static
func
alignFromBottom
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"V:[child]-(bottom)-|"
,
options
:
options
,
metrics
:
[
"bottom"
:
bottom
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignFromRight
*/
/// AlignFromRight
public
static
func
alignFromRight
(
parent
:
UIView
,
child
:
UIView
,
right
:
CGFloat
=
0
,
options
:
NSLayoutFormatOptions
=
[])
{
child
.
translatesAutoresizingMaskIntoConstraints
=
false
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
options
,
metrics
:
[
"right"
:
right
],
views
:
[
"child"
:
child
]))
}
/**
:name: constraint
*/
/// Constraint
public
static
func
constraint
(
format
:
String
,
options
:
NSLayoutFormatOptions
,
metrics
:
Dictionary
<
String
,
AnyObject
>
?,
views
:
Dictionary
<
String
,
AnyObject
>
)
->
Array
<
NSLayoutConstraint
>
{
for
(
_
,
a
)
in
views
{
if
let
v
:
UIView
=
a
as?
UIView
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
}
}
return
NSLayoutConstraint
.
constraintsWithVisualFormat
(
format
,
options
:
options
,
...
...
Sources/iOS/NavigationBar.swift
View file @
01fe9110
...
...
@@ -30,6 +30,13 @@
import
UIKit
/// NavigationBar styles.
public
enum
NavigationBarStyle
{
case
Tiny
case
Default
case
Medium
}
public
extension
UINavigationBar
{
/// Device status bar style.
public
var
statusBarStyle
:
UIStatusBarStyle
{
...
...
@@ -44,6 +51,9 @@ public extension UINavigationBar {
@IBDesignable
public
class
NavigationBar
:
UINavigationBar
{
/// NavigationBarStyle value.
public
var
navigationBarStyle
:
NavigationBarStyle
=
.
Default
/// Will render the view.
public
var
willRenderView
:
Bool
{
return
0
<
width
...
...
@@ -273,7 +283,14 @@ public class NavigationBar : UINavigationBar {
}
public
override
func
intrinsicContentSize
()
->
CGSize
{
switch
navigationBarStyle
{
case
.
Tiny
:
return
CGSizeMake
(
MaterialDevice
.
width
,
32
)
case
.
Default
:
return
CGSizeMake
(
MaterialDevice
.
width
,
44
)
case
.
Medium
:
return
CGSizeMake
(
MaterialDevice
.
width
,
56
)
}
}
public
override
func
sizeThatFits
(
size
:
CGSize
)
->
CGSize
{
...
...
@@ -302,36 +319,33 @@ public class NavigationBar : UINavigationBar {
*/
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
if
willRenderView
{
if
nil
==
item
.
titleView
{
item
.
titleView
=
UIView
(
frame
:
CGRectZero
)
}
prepareItem
(
item
)
if
let
titleView
:
UIView
=
prepareTitleView
(
item
)
{
if
let
contentView
:
UIView
=
prepareContentView
(
item
)
{
let
factor
:
CGFloat
=
24
if
let
grid
:
Int
=
Int
(
width
/
factor
)
{
let
columns
:
Int
=
grid
+
1
if
let
titleView
:
UIView
=
item
.
titleView
{
titleView
.
frame
.
origin
=
CGPointZero
titleView
.
frame
.
size
=
intrinsicContentSize
()
titleView
.
grid
.
axis
.
columns
=
Int
(
width
/
48
)
if
nil
==
item
.
contentView
{
item
.
contentView
=
UIView
()
}
if
let
contentView
:
UIView
=
item
.
contentView
{
contentView
.
grid
.
columns
=
titleView
.
grid
.
axis
.
columns
// Size of single grid column.
if
let
g
:
CGFloat
=
width
/
CGFloat
(
0
<
titleView
.
grid
.
axis
.
columns
?
titleView
.
grid
.
axis
.
columns
:
1
)
{
titleView
.
grid
.
views
=
[]
titleView
.
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
()
.
width
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
=
UIEdgeInsetsZero
}
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsetsZero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
c
.
grid
.
columns
=
0
==
g
?
1
:
Int
(
ceil
(
w
/
g
))
let
q
:
Int
=
Int
(
w
/
factor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
?
.
append
(
c
)
}
...
...
@@ -344,57 +358,53 @@ public class NavigationBar : UINavigationBar {
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
()
.
width
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
=
UIEdgeInsetsZero
}
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsetsZero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
c
.
grid
.
columns
=
0
==
g
?
1
:
Int
(
ceil
(
w
/
g
))
let
q
:
Int
=
Int
(
w
/
factor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
?
.
append
(
c
)
}
}
}
contentView
.
grid
.
views
=
[]
titleView
.
grid
.
contentInset
=
contentInset
titleView
.
grid
.
spacing
=
spacing
titleView
.
grid
.
reloadLayout
()
// contentView alignment.
if
let
title
:
String
=
item
.
title
{
if
let
t
:
UILabel
=
item
.
titleLabel
{
if
""
!=
title
{
t
.
text
=
title
if
let
titleLabel
:
UILabel
=
item
.
titleLabel
{
if
let
_
:
String
=
titleLabel
.
text
{
if
nil
==
titleLabel
.
superview
{
contentView
.
addSubview
(
titleLabel
)
}
item
.
title
=
""
if
""
!=
t
.
text
{
t
.
grid
.
rows
=
1
contentView
.
addSubview
(
t
)
contentView
.
grid
.
views
?
.
append
(
t
)
if
let
detail
:
String
=
item
.
detail
{
if
let
d
:
UILabel
=
item
.
detailLabel
{
t
.
font
=
t
.
font
.
fontWithSize
(
17
)
d
.
text
=
detail
d
.
grid
.
rows
=
1
d
.
font
=
d
.
font
.
fontWithSize
(
12
)
contentView
.
addSubview
(
d
)
contentView
.
grid
.
axis
.
rows
=
2
contentView
.
grid
.
views
?
.
append
(
d
)
if
let
detailLabel
:
UILabel
=
item
.
detailLabel
{
if
let
_
:
String
=
detailLabel
.
text
{
if
nil
==
detailLabel
.
superview
{
contentView
.
addSubview
(
detailLabel
)
}
titleLabel
.
sizeToFit
()
detailLabel
.
sizeToFit
()
let
diff
:
CGFloat
=
(
contentView
.
frame
.
height
-
titleLabel
.
frame
.
height
-
detailLabel
.
frame
.
height
)
/
2
titleLabel
.
frame
.
size
.
height
+=
diff
detailLabel
.
frame
.
size
.
height
+=
diff
detailLabel
.
frame
.
origin
.
y
=
titleLabel
.
frame
.
height
}
else
{
t
.
font
=
t
.
font
?
.
fontWithSize
(
20
)
contentView
.
grid
.
axis
.
rows
=
1
detailLabel
.
removeFromSuperview
(
)
titleLabel
.
frame
=
contentView
.
bounds
}
}
}
else
{
titleLabel
.
removeFromSuperview
()
contentView
.
grid
.
reloadLayout
()
}
}
}
titleView
.
grid
.
contentInset
=
contentInset
titleView
.
grid
.
spacing
=
spacing
titleView
.
grid
.
reloadLayout
()
contentView
.
grid
.
axis
.
direction
=
.
Vertical
contentView
.
grid
.
reloadLayout
()
}
}
}
...
...
@@ -427,4 +437,26 @@ public class NavigationBar : UINavigationBar {
shadowImage
=
image
setBackgroundImage
(
image
,
forBarMetrics
:
.
Default
)
}
/// Prepares the item.
private
func
prepareItem
(
item
:
UINavigationItem
)
{
item
.
title
=
""
}
/// Prepare the titleView.
private
func
prepareTitleView
(
item
:
UINavigationItem
)
->
UIView
{
if
nil
==
item
.
titleView
{
item
.
titleView
=
UIView
(
frame
:
CGRectZero
)
}
return
item
.
titleView
!
}
/// Prepare the contentView.
private
func
prepareContentView
(
item
:
UINavigationItem
)
->
UIView
{
if
nil
==
item
.
contentView
{
item
.
contentView
=
UIView
(
frame
:
CGRectZero
)
}
item
.
contentView
!.
grid
.
axis
.
direction
=
.
Vertical
return
item
.
contentView
!
}
}
Sources/iOS/NavigationItem.swift
View file @
01fe9110
...
...
@@ -38,13 +38,13 @@ public class MaterialAssociatedObjectNavigationItem {
public
var
contentView
:
UIView
?
/// Title label.
public
var
titleLabel
:
UILabel
public
private(set)
var
titleLabel
:
UILabel
!
/// Detail text.
public
var
detail
:
String
?
/// Detail label.
public
var
detailLabel
:
UILabel
public
private(set)
var
detailLabel
:
UILabel
!
/// Left controls.
public
var
leftControls
:
Array
<
UIControl
>
?
...
...
@@ -52,9 +52,24 @@ public class MaterialAssociatedObjectNavigationItem {
/// Right controls.
public
var
rightControls
:
Array
<
UIControl
>
?
/// Initializer.
public
init
()
{
prepareTitleLabel
()
prepareDetailLabel
()
}
/// Prepares the titleLabel.
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
17
)
titleLabel
.
textAlignment
=
.
Left
}
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
12
)
detailLabel
.
textAlignment
=
.
Left
}
}
...
...
Sources/iOS/StatusBarView.swift
View file @
01fe9110
...
...
@@ -74,7 +74,7 @@ public class StatusBarView : ControlView {
width
=
MaterialDevice
.
width
}
grid
.
axis
.
columns
=
Int
(
width
/
48
)
grid
.
axis
.
columns
=
Int
(
width
/
24
)
// General alignment.
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
isLandscape
{
...
...
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