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
165620da
Commit
165620da
authored
Mar 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated NavigationBar internals
parent
2db722d6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
17 deletions
+65
-17
Examples/Programmatic/App/App/Info.plist
+0
-2
Examples/Programmatic/App/App/RecipesViewController.swift
+3
-4
Examples/Programmatic/NavigationBar/NavigationBar/ViewController.swift
+13
-0
Sources/NavigationBar.swift
+49
-11
No files found.
Examples/Programmatic/App/App/Info.plist
View file @
165620da
...
@@ -34,8 +34,6 @@
...
@@ -34,8 +34,6 @@
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortraitUpsideDown
<
/string
>
<
string
>
UIInterfaceOrientationPortraitUpsideDown
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeLeft
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeRight
<
/string
>
<
/
a
rr
a
y
>
<
/
a
rr
a
y
>
<
k
e
y
>
UISupportedInterfaceOrientations
~
ipad
<
/k
e
y
>
<
k
e
y
>
UISupportedInterfaceOrientations
~
ipad
<
/k
e
y
>
<
a
rr
a
y
>
<
a
rr
a
y
>
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
165620da
...
@@ -165,7 +165,7 @@ class RecipesViewController: UIViewController {
...
@@ -165,7 +165,7 @@ class RecipesViewController: UIViewController {
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
=
UILabel
()
titleLabel
.
text
=
"Recipes"
titleLabel
.
text
=
"Recipes"
titleLabel
.
textAlignment
=
.
Center
titleLabel
.
textAlignment
=
.
Left
titleLabel
.
textColor
=
MaterialColor
.
white
titleLabel
.
textColor
=
MaterialColor
.
white
}
}
...
@@ -198,10 +198,9 @@ class RecipesViewController: UIViewController {
...
@@ -198,10 +198,9 @@ class RecipesViewController: UIViewController {
/// Prepares the NavigationBar.
/// Prepares the NavigationBar.
private
func
prepareNavigationBar
()
{
private
func
prepareNavigationBar
()
{
// navigationItem.title = "Recipes"
navigationItem
.
titleLabel
=
titleLabel
navigationItem
.
titleLabel
=
titleLabel
//
navigationItem.leftControls = [menuButton]
navigationItem
.
leftControls
=
[
menuButton
]
//
navigationItem.rightControls = [switchControl, searchButton]
navigationItem
.
rightControls
=
[
switchControl
,
searchButton
]
}
}
/// Prepares the tableView.
/// Prepares the tableView.
...
...
Examples/Programmatic/NavigationBar/NavigationBar/ViewController.swift
View file @
165620da
...
@@ -35,6 +35,9 @@ class ViewController: UIViewController {
...
@@ -35,6 +35,9 @@ class ViewController: UIViewController {
/// NavigationBar title label.
/// NavigationBar title label.
private
var
titleLabel
:
UILabel
!
private
var
titleLabel
:
UILabel
!
/// NavigationBar detail label.
private
var
detailLabel
:
UILabel
!
/// NavigationBar menu button.
/// NavigationBar menu button.
private
var
menuButton
:
FlatButton
!
private
var
menuButton
:
FlatButton
!
...
@@ -51,6 +54,7 @@ class ViewController: UIViewController {
...
@@ -51,6 +54,7 @@ class ViewController: UIViewController {
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
prepareTitleLabel
()
prepareTitleLabel
()
prepareDetailLabel
()
prepareMenuButton
()
prepareMenuButton
()
prepareSwitchControl
()
prepareSwitchControl
()
prepareSearchButton
()
prepareSearchButton
()
...
@@ -75,6 +79,14 @@ class ViewController: UIViewController {
...
@@ -75,6 +79,14 @@ class ViewController: UIViewController {
titleLabel
.
textColor
=
MaterialColor
.
white
titleLabel
.
textColor
=
MaterialColor
.
white
}
}
/// Prepares the titleLabel.
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
.
text
=
"8 Items"
detailLabel
.
textAlignment
=
.
Left
detailLabel
.
textColor
=
MaterialColor
.
white
}
/// Prepares the menuButton.
/// Prepares the menuButton.
private
func
prepareMenuButton
()
{
private
func
prepareMenuButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
menu
let
image
:
UIImage
?
=
MaterialIcon
.
menu
...
@@ -111,6 +123,7 @@ class ViewController: UIViewController {
...
@@ -111,6 +123,7 @@ class ViewController: UIViewController {
let
item
:
UINavigationItem
=
UINavigationItem
()
let
item
:
UINavigationItem
=
UINavigationItem
()
item
.
titleLabel
=
titleLabel
item
.
titleLabel
=
titleLabel
item
.
detailLabel
=
detailLabel
item
.
leftControls
=
[
menuButton
]
item
.
leftControls
=
[
menuButton
]
item
.
rightControls
=
[
switchControl
,
searchButton
]
item
.
rightControls
=
[
switchControl
,
searchButton
]
navigationBar
.
pushNavigationItem
(
item
,
animated
:
true
)
navigationBar
.
pushNavigationItem
(
item
,
animated
:
true
)
...
...
Sources/NavigationBar.swift
View file @
165620da
...
@@ -254,7 +254,44 @@ public class NavigationBar : UINavigationBar {
...
@@ -254,7 +254,44 @@ public class NavigationBar : UINavigationBar {
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
topItem
?
.
titleView
?
.
backgroundColor
=
MaterialColor
.
green
.
base
let
h
:
CGFloat
=
intrinsicContentSize
()
.
height
let
w
:
CGFloat
=
backButton
.
intrinsicContentSize
()
.
width
if
let
v
:
Array
<
UIControl
>
=
topItem
?
.
leftControls
{
for
c
in
v
{
c
.
bounds
.
size
=
c
is
MaterialSwitch
?
CGSizeMake
(
w
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
:
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
}
}
if
let
t
:
UILabel
=
topItem
?
.
titleLabel
{
t
.
grid
.
rows
=
1
topItem
?
.
titleView
?
.
grid
.
views
=
[
t
]
if
32
>=
height
||
nil
==
topItem
?
.
detailLabel
{
t
.
font
=
t
.
font
.
fontWithSize
(
20
)
topItem
?
.
titleView
?
.
grid
.
axis
.
rows
=
1
topItem
?
.
detailLabel
?
.
hidden
=
true
}
else
if
let
d
:
UILabel
=
topItem
?
.
detailLabel
{
d
.
grid
.
rows
=
1
d
.
hidden
=
false
d
.
font
=
d
.
font
.
fontWithSize
(
12
)
t
.
font
=
t
.
font
.
fontWithSize
(
17
)
topItem
?
.
titleView
?
.
grid
.
axis
.
rows
=
2
topItem
?
.
titleView
?
.
grid
.
views
?
.
append
(
d
)
}
}
if
let
v
:
Array
<
UIControl
>
=
topItem
?
.
rightControls
{
for
c
in
v
{
c
.
bounds
.
size
=
c
is
MaterialSwitch
?
CGSizeMake
(
w
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
:
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
}
}
topItem
?
.
titleView
?
.
grid
.
reloadLayout
()
}
}
public
override
func
pushNavigationItem
(
item
:
UINavigationItem
,
animated
:
Bool
)
{
public
override
func
pushNavigationItem
(
item
:
UINavigationItem
,
animated
:
Bool
)
{
...
@@ -293,10 +330,11 @@ public class NavigationBar : UINavigationBar {
...
@@ -293,10 +330,11 @@ public class NavigationBar : UINavigationBar {
item
.
leftBarButtonItems
=
n
.
reverse
()
item
.
leftBarButtonItems
=
n
.
reverse
()
}
}
//
If title is empty
//
Set the titleView if title is empty.
if
""
==
item
.
title
{
if
nil
==
item
.
title
{
if
nil
==
item
.
titleView
{
if
nil
==
item
.
titleView
{
item
.
titleView
=
UIView
(
frame
:
CGRectMake
(
0
,
contentInset
.
top
,
MaterialDevice
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
))
item
.
titleView
=
UIView
(
frame
:
CGRectMake
(
0
,
contentInset
.
top
,
MaterialDevice
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
))
item
.
titleView
!.
autoresizingMask
=
.
FlexibleWidth
item
.
titleView
!.
grid
.
axis
.
direction
=
.
Vertical
item
.
titleView
!.
grid
.
axis
.
direction
=
.
Vertical
}
}
...
@@ -309,12 +347,7 @@ public class NavigationBar : UINavigationBar {
...
@@ -309,12 +347,7 @@ public class NavigationBar : UINavigationBar {
item
.
titleView
!.
addSubview
(
t
)
item
.
titleView
!.
addSubview
(
t
)
item
.
titleView
!.
grid
.
views
?
.
append
(
t
)
item
.
titleView
!.
grid
.
views
?
.
append
(
t
)
if
32
>=
height
||
nil
==
item
.
detailLabel
{
if
let
d
:
UILabel
=
item
.
detailLabel
{
t
.
font
=
t
.
font
?
.
fontWithSize
(
17
)
item
.
titleView
!.
grid
.
axis
.
rows
=
1
item
.
detailLabel
?
.
hidden
=
true
}
else
if
let
d
:
UILabel
=
item
.
detailLabel
{
d
.
grid
.
rows
=
1
d
.
grid
.
rows
=
1
d
.
hidden
=
false
d
.
hidden
=
false
d
.
font
=
d
.
font
.
fontWithSize
(
12
)
d
.
font
=
d
.
font
.
fontWithSize
(
12
)
...
@@ -324,6 +357,11 @@ public class NavigationBar : UINavigationBar {
...
@@ -324,6 +357,11 @@ public class NavigationBar : UINavigationBar {
item
.
titleView
!.
addSubview
(
d
)
item
.
titleView
!.
addSubview
(
d
)
item
.
titleView
!.
grid
.
axis
.
rows
=
2
item
.
titleView
!.
grid
.
axis
.
rows
=
2
item
.
titleView
!.
grid
.
views
?
.
append
(
d
)
item
.
titleView
!.
grid
.
views
?
.
append
(
d
)
}
else
{
t
.
font
=
t
.
font
?
.
fontWithSize
(
20
)
item
.
titleView
!.
grid
.
axis
.
rows
=
1
item
.
detailLabel
?
.
hidden
=
true
}
}
}
else
if
let
d
:
UIView
=
item
.
detailView
{
}
else
if
let
d
:
UIView
=
item
.
detailView
{
d
.
grid
.
rows
=
1
d
.
grid
.
rows
=
1
...
@@ -382,8 +420,8 @@ public class NavigationBar : UINavigationBar {
...
@@ -382,8 +420,8 @@ public class NavigationBar : UINavigationBar {
/// Prepares the UINavigationItem for layout and sizing.
/// Prepares the UINavigationItem for layout and sizing.
internal
func
prepareItem
(
item
:
UINavigationItem
)
{
internal
func
prepareItem
(
item
:
UINavigationItem
)
{
if
nil
==
item
.
title
{
if
""
==
item
.
title
{
item
.
title
=
""
item
.
title
=
nil
}
}
}
}
}
}
...
...
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