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
ff3b0d89
Commit
ff3b0d89
authored
Mar 07, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated ordering when adding back button support for NavigationBar
parent
d56c1135
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
32 deletions
+28
-32
Examples/Programmatic/App/App/MessagesViewController.swift
+4
-6
Sources/NavigationBar.swift
+18
-25
Sources/NavigationController.swift
+6
-1
No files found.
Examples/Programmatic/App/App/MessagesViewController.swift
View file @
ff3b0d89
...
...
@@ -78,17 +78,15 @@ class MessagesViewController: UIViewController {
detailLabel
.
textAlignment
=
.
Left
detailLabel
.
textColor
=
MaterialColor
.
white
navigationItem
.
titleLabel
=
titleLabel
navigationItem
.
detailLabel
=
detailLabel
let
image
:
UIImage
?
=
UIImage
(
named
:
"ic_share_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
image
:
UIImage
?
=
UIImage
(
named
:
"ic_share_white"
)
let
shareButton
:
FlatButton
=
FlatButton
()
shareButton
.
pulseScale
=
false
shareButton
.
pulseColor
=
MaterialColor
.
grey
.
base
shareButton
.
tintColor
=
MaterialColor
.
grey
.
base
shareButton
.
pulseColor
=
MaterialColor
.
white
shareButton
.
setImage
(
image
,
forState
:
.
Normal
)
shareButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
navigationItem
.
titleLabel
=
titleLabel
navigationItem
.
detailLabel
=
detailLabel
navigationItem
.
rightControls
=
[
shareButton
]
}
...
...
Sources/NavigationBar.swift
View file @
ff3b0d89
...
...
@@ -379,6 +379,7 @@ public class NavigationBar : UINavigationBar {
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
var
n
:
Array
<
UIBarButtonItem
>
=
Array
<
UIBarButtonItem
>
()
for
c
in
v
{
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
=
UIEdgeInsetsZero
...
...
@@ -386,8 +387,16 @@ public class NavigationBar : UINavigationBar {
c
.
grid
.
columns
=
0
==
g
?
1
:
Int
(
ceil
(
c
.
intrinsicContentSize
()
.
width
/
g
))
columns
-=
c
.
grid
.
columns
grid
.
views
?
.
append
(
c
)
grid
.
views
!.
append
(
c
)
n
.
append
(
UIBarButtonItem
(
customView
:
c
))
}
// let spacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
// spacer.width = 0
// c.append(spacer)
item
.
leftBarButtonItems
=
n
.
reverse
()
}
if
nil
==
item
.
titleView
{
...
...
@@ -426,6 +435,7 @@ public class NavigationBar : UINavigationBar {
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
var
n
:
Array
<
UIBarButtonItem
>
=
Array
<
UIBarButtonItem
>
()
for
c
in
v
{
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
=
UIEdgeInsetsZero
...
...
@@ -435,7 +445,14 @@ public class NavigationBar : UINavigationBar {
columns
-=
c
.
grid
.
columns
grid
.
views
!.
append
(
c
)
n
.
append
(
UIBarButtonItem
(
customView
:
c
))
}
// let spacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
// spacer.width = 0
// c.append(spacer)
item
.
rightBarButtonItems
=
n
.
reverse
()
}
item
.
titleView
!.
grid
.
columns
=
columns
...
...
@@ -560,19 +577,7 @@ public extension UINavigationItem {
return
controls
.
leftControls
}
set
(
value
)
{
var
c
:
Array
<
UIBarButtonItem
>
=
Array
<
UIBarButtonItem
>
()
if
let
v
:
Array
<
UIControl
>
=
value
{
for
q
in
v
{
c
.
append
(
UIBarButtonItem
(
customView
:
q
))
}
}
let
spacer
:
UIBarButtonItem
=
UIBarButtonItem
(
barButtonSystemItem
:
.
FixedSpace
,
target
:
nil
,
action
:
nil
)
spacer
.
width
=
0
c
.
append
(
spacer
)
controls
.
leftControls
=
value
leftBarButtonItems
=
c
.
reverse
()
}
}
...
...
@@ -582,19 +587,7 @@ public extension UINavigationItem {
return
controls
.
rightControls
}
set
(
value
)
{
var
c
:
Array
<
UIBarButtonItem
>
=
Array
<
UIBarButtonItem
>
()
if
let
v
:
Array
<
UIControl
>
=
value
{
for
q
in
v
{
c
.
append
(
UIBarButtonItem
(
customView
:
q
))
}
}
let
spacer
:
UIBarButtonItem
=
UIBarButtonItem
(
barButtonSystemItem
:
.
FixedSpace
,
target
:
nil
,
action
:
nil
)
spacer
.
width
=
0
c
.
append
(
spacer
)
controls
.
rightControls
=
value
rightBarButtonItems
=
c
.
reverse
()
}
}
}
...
...
Sources/NavigationController.swift
View file @
ff3b0d89
...
...
@@ -73,7 +73,12 @@ public class NavigationController : UINavigationController, UINavigationBarDeleg
public
func
navigationBar
(
navigationBar
:
UINavigationBar
,
didPushItem
item
:
UINavigationItem
)
{
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
item
.
leftControls
=
[
backButton
]
if
var
c
:
Array
<
UIControl
>
=
item
.
leftControls
{
c
.
append
(
backButton
)
item
.
leftControls
=
c
}
else
{
item
.
leftControls
=
[
backButton
]
}
v
.
layoutNavigationItem
(
item
)
}
}
...
...
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