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
5e6d8784
Commit
5e6d8784
authored
Mar 08, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NavigationBar working with all device sizes.
parent
92f6000c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
19 deletions
+32
-19
Examples/Programmatic/App/App/InboxViewController.swift
+15
-0
Examples/Programmatic/NavigationBar/NavigationBar/ViewController.swift
+5
-1
Sources/NavigationBar.swift
+12
-8
Sources/NavigationController.swift
+0
-10
No files found.
Examples/Programmatic/App/App/InboxViewController.swift
View file @
5e6d8784
...
...
@@ -44,6 +44,9 @@ class InboxViewController: UIViewController {
/// NavigationBar detail label.
private
var
detailLabel
:
UILabel
!
/// NavigationBar share button.
private
var
shareButton
:
FlatButton
!
/// A tableView used to display Bond entries.
private
var
tableView
:
UITableView
!
...
...
@@ -55,6 +58,7 @@ class InboxViewController: UIViewController {
prepareItems
()
prepareTitleLabel
()
prepareDetailLabel
()
prepareShareButton
()
prepareNavigationBar
()
prepareTableView
()
}
...
...
@@ -84,6 +88,7 @@ class InboxViewController: UIViewController {
private
func
prepareNavigationBar
()
{
navigationItem
.
titleLabel
=
titleLabel
navigationItem
.
detailLabel
=
detailLabel
navigationItem
.
rightControls
=
[
shareButton
]
}
/// Prepares the items Array.
...
...
@@ -127,6 +132,16 @@ class InboxViewController: UIViewController {
detailLabel
.
textAlignment
=
.
Left
detailLabel
.
textColor
=
MaterialColor
.
white
}
/// Prepares the shareButton.
private
func
prepareShareButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
share
shareButton
=
FlatButton
()
shareButton
.
pulseScale
=
false
shareButton
.
pulseColor
=
MaterialColor
.
white
shareButton
.
setImage
(
image
,
forState
:
.
Normal
)
shareButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
}
}
/// TableViewDataSource methods.
...
...
Examples/Programmatic/NavigationBar/NavigationBar/ViewController.swift
View file @
5e6d8784
...
...
@@ -103,10 +103,14 @@ class ViewController: UIViewController {
/// Prepare navigationBar.
private
func
prepareNavigationBar
()
{
navigationBar
=
NavigationBar
()
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
navigationBar
.
statusBarStyle
=
.
LightContent
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
view
.
addSubview
(
navigationBar
)
menuButton
.
backgroundColor
=
MaterialColor
.
yellow
.
accent1
let
item
:
UINavigationItem
=
UINavigationItem
()
item
.
titleLabel
=
titleLabel
item
.
leftControls
=
[
menuButton
]
...
...
Sources/NavigationBar.swift
View file @
5e6d8784
...
...
@@ -249,7 +249,10 @@ public class NavigationBar : UINavigationBar {
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
let
item
:
UINavigationItem
=
topItem
{
if
let
item
:
UINavigationItem
=
backItem
{
item
.
titleView
?
.
grid
.
reloadLayout
()
}
else
if
let
item
:
UINavigationItem
=
topItem
{
layoutNavigationItem
(
item
)
}
}
...
...
@@ -267,6 +270,7 @@ public class NavigationBar : UINavigationBar {
prepareItem
(
item
)
let
h
:
CGFloat
=
intrinsicContentSize
()
.
height
let
w
:
CGFloat
=
backButton
.
intrinsicContentSize
()
.
width
let
inset
:
CGFloat
=
MaterialDevice
.
landscape
?
item
.
landscapeInset
:
item
.
portraitInset
// leftControls
...
...
@@ -277,7 +281,7 @@ public class NavigationBar : UINavigationBar {
b
.
contentEdgeInsets
.
top
=
0
b
.
contentEdgeInsets
.
bottom
=
0
}
c
.
bounds
.
size
=
c
is
MaterialSwitch
?
CGSizeMake
(
backButton
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
:
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
c
.
bounds
.
size
=
c
is
MaterialSwitch
?
CGSizeMake
(
w
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
:
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
n
.
append
(
UIBarButtonItem
(
customView
:
c
))
}
...
...
@@ -290,11 +294,12 @@ public class NavigationBar : UINavigationBar {
}
if
nil
==
item
.
titleView
{
item
.
titleView
=
UIView
(
frame
:
CGRectMake
(
0
,
contentInset
.
top
,
MaterialDevice
.
width
<
MaterialDevice
.
height
?
MaterialDevice
.
height
:
MaterialDevice
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
)
item
.
titleView
=
UIView
()
item
.
titleView
!.
backgroundColor
=
nil
item
.
titleView
!.
grid
.
axis
.
direction
=
.
Vertical
}
item
.
titleView
!.
frame
=
CGRectMake
(
0
,
contentInset
.
top
,
MaterialDevice
.
width
<
MaterialDevice
.
height
?
MaterialDevice
.
height
:
MaterialDevice
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
item
.
titleView
!.
grid
.
views
=
[]
// TitleView alignment.
...
...
@@ -334,13 +339,13 @@ public class NavigationBar : UINavigationBar {
b
.
contentEdgeInsets
.
top
=
0
b
.
contentEdgeInsets
.
bottom
=
0
}
c
.
bounds
.
size
=
c
is
MaterialSwitch
?
CGSizeMake
(
backButton
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
:
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
c
.
bounds
.
size
=
c
is
MaterialSwitch
?
CGSizeMake
(
w
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
:
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
n
.
append
(
UIBarButtonItem
(
customView
:
c
))
}
// The spacer moves the UIBarButtonItems to the edge of the UINavigationBar.
let
spacer
:
UIBarButtonItem
=
UIBarButtonItem
(
barButtonSystemItem
:
.
FixedSpace
,
target
:
nil
,
action
:
nil
)
spacer
.
width
=
inset
+
contentInset
.
lef
t
spacer
.
width
=
inset
+
contentInset
.
righ
t
n
.
append
(
spacer
)
item
.
rightBarButtonItems
=
n
.
reverse
()
...
...
@@ -362,6 +367,7 @@ public class NavigationBar : UINavigationBar {
backButtonImage
=
nil
backgroundColor
=
MaterialColor
.
white
depth
=
.
Depth1
contentInset
=
UIEdgeInsetsMake
(
2
,
6
,
2
,
6
)
prepareBackButton
()
}
...
...
@@ -375,9 +381,7 @@ public class NavigationBar : UINavigationBar {
/// Prepares the UINavigationItem for layout and sizing.
internal
func
prepareItem
(
item
:
UINavigationItem
)
{
if
nil
==
item
.
title
{
item
.
title
=
""
}
item
.
title
=
""
}
}
...
...
Sources/NavigationController.swift
View file @
5e6d8784
...
...
@@ -64,16 +64,6 @@ public class NavigationController : UINavigationController {
interactivePopGestureRecognizer
?
.
delegate
=
nil
}
public
override
func
viewDidAppear
(
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
if
let
v
:
UINavigationItem
=
navigationBar
.
topItem
{
if
let
b
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
b
.
layoutNavigationItem
(
v
)
}
}
}
/**
Delegation method that is called when a new UINavigationItem is about to be pushed.
This is used to prepare the transitions between UIViewControllers on the stack.
...
...
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