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
7d7e0975
Commit
7d7e0975
authored
Mar 06, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working NavigationController -> NavigationBar Back Button
parent
0ff4ab03
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
277 additions
and
258 deletions
+277
-258
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
+0
-4
Examples/Programmatic/App/App/AppDelegate.swift
+1
-1
Examples/Programmatic/App/App/FeedViewController.swift
+12
-8
Examples/Programmatic/App/App/InboxViewController.swift
+5
-2
Examples/Programmatic/App/App/Info.plist
+4
-2
Examples/Programmatic/App/App/ViewController.swift
+0
-58
Sources/Grid.swift
+1
-1
Sources/MaterialEdgeInset.swift
+28
-30
Sources/NavigationBar.swift
+213
-143
Sources/NavigationController.swift
+10
-8
Sources/SideNavigationViewController.swift
+3
-1
No files found.
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
View file @
7d7e0975
...
...
@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
96334EFC1C8B85F40083986B
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFB1C8B85F40083986B
/* Material.framework */
;
};
96334EFD1C8B85F40083986B
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFB1C8B85F40083986B
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96334EFF1C8B876E0083986B
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFE1C8B876E0083986B
/* ViewController.swift */
;
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
9663F9341C7A744600AF0965
/* SearchListViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9331C7A744600AF0965
/* SearchListViewController.swift */
;
};
9663F9391C7A744600AF0965
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9381C7A744600AF0965
/* Assets.xcassets */
;
};
...
...
@@ -39,7 +38,6 @@
/* Begin PBXFileReference section */
96334EFB1C8B85F40083986B
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96334EFE1C8B876E0083986B
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
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
/* SearchListViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SearchListViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -99,7 +97,6 @@
9663F9381C7A744600AF0965
/* Assets.xcassets */
,
9663F93A1C7A744600AF0965
/* LaunchScreen.storyboard */
,
9663F93D1C7A744600AF0965
/* Info.plist */
,
96334EFE1C8B876E0083986B
/* ViewController.swift */
,
);
path
=
App
;
sourceTree
=
"<group>"
;
...
...
@@ -175,7 +172,6 @@
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
96334EFF1C8B876E0083986B
/* ViewController.swift in Sources */
,
9663F94A1C7A74B500AF0965
/* AppSearchBarViewController.swift in Sources */
,
96CC08881C7FEBD60034FF84
/* InboxViewController.swift in Sources */
,
9663F9501C7A74FC00AF0965
/* AppRightViewController.swift in Sources */
,
...
...
Examples/Programmatic/App/App/AppDelegate.swift
View file @
7d7e0975
...
...
@@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
// window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: InboxViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window
!.
rootViewController
=
NavigationController
(
rootViewController
:
Feed
ViewController
())
window
!.
rootViewController
=
SideNavigationViewController
(
mainViewController
:
NavigationController
(
rootViewController
:
FeedViewController
()),
leftViewController
:
AppLeft
ViewController
())
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/App/App/FeedViewController.swift
View file @
7d7e0975
...
...
@@ -46,7 +46,6 @@ class FeedViewController: UIViewController {
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
collectionView
.
frame
=
view
.
bounds
collectionView
.
reloadData
()
}
...
...
@@ -59,11 +58,11 @@ class FeedViewController: UIViewController {
// Menu button.
let
menuButton
:
FlatButton
=
FlatButton
()
menuButton
.
pulseColor
=
MaterialColor
.
white
menuButton
.
pulseScale
=
false
menuButton
.
pulseColor
=
MaterialColor
.
white
menuButton
.
setImage
(
image
,
forState
:
.
Normal
)
menuButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
//
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
menuButton
.
addTarget
(
self
,
action
:
"handleMenuButton"
,
forControlEvents
:
.
TouchUpInside
)
// Switch control.
let
switchControl
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Small
)
...
...
@@ -71,18 +70,18 @@ class FeedViewController: UIViewController {
// Search button.
image
=
UIImage
(
named
:
"ic_search_white"
)
let
searchButton
:
FlatButton
=
FlatButton
()
searchButton
.
pulseColor
=
MaterialColor
.
white
searchButton
.
pulseScale
=
false
searchButton
.
pulseColor
=
MaterialColor
.
white
searchButton
.
setImage
(
image
,
forState
:
.
Normal
)
searchButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
//
searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
searchButton
.
addTarget
(
self
,
action
:
"handleSearchButton"
,
forControlEvents
:
.
TouchUpInside
)
navigationController
?
.
navigationBar
.
leftControls
=
[
menuButton
]
navigationController
?
.
navigationBar
.
rightControls
=
[
switchControl
,
searchButton
]
}
internal
func
handleMenuButton
()
{
print
(
"handled"
)
sideNavigationViewController
?
.
toggleLeftView
(
)
}
internal
func
handleSearchButton
()
{
...
...
@@ -94,7 +93,9 @@ class FeedViewController: UIViewController {
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten4
navigationController
?
.
navigationBar
.
statusBarStyle
=
.
LightContent
navigationController
?
.
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationController
?
.
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
navigationController
?
.
navigationBar
.
backButton
.
pulseColor
=
MaterialColor
.
white
}
/// Prepares the collectionView
...
...
@@ -102,11 +103,12 @@ class FeedViewController: UIViewController {
collectionView
.
dataSource
=
self
collectionView
.
delegate
=
self
collectionView
.
spacingPreset
=
.
Spacing1
collectionView
.
contentInsetPreset
=
.
Square1
collectionView
.
registerClass
(
MaterialCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
"MaterialCollectionViewCell"
)
// To avoid being hidden under the hovering MenuView.
view
.
addSubview
(
collectionView
)
collectionView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
view
,
child
:
collectionView
)
// collectionView.scrollDirection = .Horizontal // Uncomment to see the horizontal scroll direction.
}
...
...
@@ -204,6 +206,7 @@ extension FeedViewController: MaterialCollectionViewDataSource {
cardView
!.
pulseScale
=
false
cardView
!.
divider
=
false
cardView
!.
depth
=
.
None
cardView
!.
cornerRadiusPreset
=
.
None
let
titleLabel
:
UILabel
=
UILabel
()
titleLabel
.
textColor
=
MaterialColor
.
grey
.
darken4
...
...
@@ -246,6 +249,6 @@ extension FeedViewController: MaterialCollectionViewDelegate {
/// Executed when an item is selected.
func
collectionView
(
collectionView
:
UICollectionView
,
didSelectItemAtIndexPath
indexPath
:
NSIndexPath
)
{
// print(indexPath)
navigationController
?
.
pushViewController
(
ViewController
(),
animated
:
true
)
navigationController
?
.
pushViewController
(
Inbox
ViewController
(),
animated
:
true
)
}
}
\ No newline at end of file
Examples/Programmatic/App/App/InboxViewController.swift
View file @
7d7e0975
...
...
@@ -53,7 +53,10 @@ class InboxViewController: UIViewController {
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
navigationBarViewController
?
.
navigationBarView
.
titleLabel
?
.
text
=
"Inbox"
navigationItem
.
title
=
"Messages"
navigationController
?
.
navigationBar
.
topItem
?
.
title
=
""
navigationController
?
.
navigationBar
.
leftControls
=
[]
}
/**
...
...
@@ -135,7 +138,7 @@ extension InboxViewController: UITableViewDataSource {
header
.
addSubview
(
label
)
label
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
header
,
child
:
label
,
left
:
navigation
BarViewController
!.
navigationBarView
.
contentInset
.
left
+
navigationBarViewController
!.
navigationBarView
.
spacing
)
MaterialLayout
.
alignToParent
(
header
,
child
:
label
,
left
:
navigation
Controller
!.
navigationBar
.
contentInset
.
left
)
return
header
}
...
...
Examples/Programmatic/App/App/Info.plist
View file @
7d7e0975
...
...
@@ -2,8 +2,6 @@
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
string
>
en
<
/string
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
...
...
@@ -30,6 +28,8 @@
<
a
rr
a
y
>
<
string
>
armv7
<
/string
>
<
/
a
rr
a
y
>
<
k
e
y
>
UIStatusBarHidden
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
...
...
@@ -44,5 +44,7 @@
<
string
>
UIInterfaceOrientationLandscapeLeft
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeRight
<
/string
>
<
/
a
rr
a
y
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
fa
ls
e
/
>
<
/
d
i
c
t
>
<
/plist
>
Examples/Programmatic/App/App/ViewController.swift
deleted
100644 → 0
View file @
0ff4ab03
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
The following example shows how to dynamically size MaterialCollectionViewCells.
*/
import
UIKit
import
Material
class
ViewController
:
UIViewController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
}
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
navigationItem
.
title
=
"Material"
navigationController
?
.
navigationBar
.
leftControls
=
[]
navigationController
?
.
navigationBar
.
rightControls
=
[]
}
/// Prepares view.
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten4
}
}
\ No newline at end of file
Sources/Grid.swift
View file @
7d7e0975
...
...
@@ -228,7 +228,7 @@ private var GridKey: UInt8 = 0
/// Grid extension for UIView.
public
extension
UIView
{
/// Grid reference.
public
var
grid
:
Grid
{
public
internal(set)
var
grid
:
Grid
{
get
{
return
MaterialObjectAssociatedObject
(
self
,
key
:
&
GridKey
)
{
return
Grid
()
...
...
Sources/MaterialEdgeInset.swift
View file @
7d7e0975
...
...
@@ -67,9 +67,7 @@ public enum MaterialEdgeInset {
case
TallRectangle9
}
/**
:name: MaterialEdgeInsetToValue
*/
/// Converts the MaterialEdgeInset to a UIEdgeInsets value.
public
func
MaterialEdgeInsetToValue
(
inset
:
MaterialEdgeInset
)
->
UIEdgeInsets
{
switch
inset
{
case
.
None
:
...
...
@@ -77,62 +75,62 @@ public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets {
// square
case
.
Square1
:
return
UIEdgeInsets
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
return
UIEdgeInsets
Make
(
4
,
4
,
4
,
4
)
case
.
Square2
:
return
UIEdgeInsets
(
top
:
8
,
left
:
8
,
bottom
:
8
,
right
:
8
)
return
UIEdgeInsets
Make
(
8
,
8
,
8
,
8
)
case
.
Square3
:
return
UIEdgeInsets
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
return
UIEdgeInsets
Make
(
16
,
16
,
16
,
16
)
case
.
Square4
:
return
UIEdgeInsets
(
top
:
24
,
left
:
24
,
bottom
:
24
,
right
:
24
)
return
UIEdgeInsets
Make
(
24
,
24
,
24
,
24
)
case
.
Square5
:
return
UIEdgeInsets
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
return
UIEdgeInsets
Make
(
32
,
32
,
32
,
32
)
case
.
Square6
:
return
UIEdgeInsets
(
top
:
40
,
left
:
40
,
bottom
:
40
,
right
:
40
)
return
UIEdgeInsets
Make
(
40
,
40
,
40
,
40
)
case
.
Square7
:
return
UIEdgeInsets
(
top
:
48
,
left
:
48
,
bottom
:
48
,
right
:
48
)
return
UIEdgeInsets
Make
(
48
,
48
,
48
,
48
)
case
.
Square8
:
return
UIEdgeInsets
(
top
:
56
,
left
:
56
,
bottom
:
56
,
right
:
56
)
return
UIEdgeInsets
Make
(
56
,
56
,
56
,
56
)
case
.
Square9
:
return
UIEdgeInsets
(
top
:
64
,
left
:
64
,
bottom
:
64
,
right
:
64
)
return
UIEdgeInsets
Make
(
64
,
64
,
64
,
64
)
// rectangle
case
.
WideRectangle1
:
return
UIEdgeInsets
(
top
:
2
,
left
:
4
,
bottom
:
2
,
right
:
4
)
return
UIEdgeInsets
Make
(
2
,
4
,
2
,
4
)
case
.
WideRectangle2
:
return
UIEdgeInsets
(
top
:
4
,
left
:
8
,
bottom
:
4
,
right
:
8
)
return
UIEdgeInsets
Make
(
4
,
8
,
4
,
8
)
case
.
WideRectangle3
:
return
UIEdgeInsets
(
top
:
8
,
left
:
16
,
bottom
:
8
,
right
:
16
)
return
UIEdgeInsets
Make
(
8
,
16
,
8
,
16
)
case
.
WideRectangle4
:
return
UIEdgeInsets
(
top
:
12
,
left
:
24
,
bottom
:
12
,
right
:
24
)
return
UIEdgeInsets
Make
(
12
,
24
,
12
,
24
)
case
.
WideRectangle5
:
return
UIEdgeInsets
(
top
:
16
,
left
:
32
,
bottom
:
16
,
right
:
32
)
return
UIEdgeInsets
Make
(
16
,
32
,
16
,
32
)
case
.
WideRectangle6
:
return
UIEdgeInsets
(
top
:
20
,
left
:
40
,
bottom
:
20
,
right
:
40
)
return
UIEdgeInsets
Make
(
20
,
40
,
20
,
40
)
case
.
WideRectangle7
:
return
UIEdgeInsets
(
top
:
24
,
left
:
48
,
bottom
:
24
,
right
:
48
)
return
UIEdgeInsets
Make
(
24
,
48
,
24
,
48
)
case
.
WideRectangle8
:
return
UIEdgeInsets
(
top
:
28
,
left
:
56
,
bottom
:
28
,
right
:
56
)
return
UIEdgeInsets
Make
(
28
,
56
,
28
,
56
)
case
.
WideRectangle9
:
return
UIEdgeInsets
(
top
:
32
,
left
:
64
,
bottom
:
32
,
right
:
64
)
return
UIEdgeInsets
Make
(
32
,
64
,
32
,
64
)
// flipped rectangle
case
.
TallRectangle1
:
return
UIEdgeInsets
(
top
:
4
,
left
:
2
,
bottom
:
4
,
right
:
2
)
return
UIEdgeInsets
Make
(
4
,
2
,
4
,
2
)
case
.
TallRectangle2
:
return
UIEdgeInsets
(
top
:
8
,
left
:
4
,
bottom
:
8
,
right
:
4
)
return
UIEdgeInsets
Make
(
8
,
4
,
8
,
4
)
case
.
TallRectangle3
:
return
UIEdgeInsets
(
top
:
16
,
left
:
8
,
bottom
:
16
,
right
:
8
)
return
UIEdgeInsets
Make
(
16
,
8
,
16
,
8
)
case
.
TallRectangle4
:
return
UIEdgeInsets
(
top
:
24
,
left
:
12
,
bottom
:
24
,
right
:
12
)
return
UIEdgeInsets
Make
(
24
,
12
,
24
,
12
)
case
.
TallRectangle5
:
return
UIEdgeInsets
(
top
:
32
,
left
:
16
,
bottom
:
32
,
right
:
16
)
return
UIEdgeInsets
Make
(
32
,
16
,
32
,
16
)
case
.
TallRectangle6
:
return
UIEdgeInsets
(
top
:
40
,
left
:
20
,
bottom
:
40
,
right
:
20
)
return
UIEdgeInsets
Make
(
40
,
20
,
40
,
20
)
case
.
TallRectangle7
:
return
UIEdgeInsets
(
top
:
48
,
left
:
24
,
bottom
:
48
,
right
:
24
)
return
UIEdgeInsets
Make
(
48
,
24
,
48
,
24
)
case
.
TallRectangle8
:
return
UIEdgeInsets
(
top
:
56
,
left
:
28
,
bottom
:
56
,
right
:
28
)
return
UIEdgeInsets
Make
(
56
,
28
,
56
,
28
)
case
.
TallRectangle9
:
return
UIEdgeInsets
(
top
:
64
,
left
:
32
,
bottom
:
64
,
right
:
32
)
return
UIEdgeInsets
Make
(
64
,
32
,
64
,
32
)
}
}
Sources/NavigationBar.swift
View file @
7d7e0975
This diff is collapsed.
Click to expand it.
Sources/NavigationController.swift
View file @
7d7e0975
...
...
@@ -34,26 +34,28 @@ public class NavigationController : UINavigationController {
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NSBundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
prepareView
()
}
public
override
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
navigationBarClass
:
NavigationBar
.
self
,
toolbarClass
:
nil
)
setViewControllers
([
rootViewController
],
animated
:
false
)
prepareView
()
}
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
public
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
v
.
layoutSubviews
()
v
.
backButton
.
removeTarget
(
self
,
action
:
"handleBackButton"
,
forControlEvents
:
.
TouchUpInside
)
v
.
backButton
.
addTarget
(
self
,
action
:
"handleBackButton"
,
forControlEvents
:
.
TouchUpInside
)
}
}
public
func
prepareView
()
{
navigationItem
.
title
=
"Title"
/// Handles the backButton.
internal
func
handleBackButton
()
{
popViewControllerAnimated
(
true
)
}
}
Sources/SideNavigationViewController.swift
View file @
7d7e0975
...
...
@@ -843,12 +843,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
private
func
toggleStatusBar
(
hide
:
Bool
=
false
)
{
if
hideStatusBar
{
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
// General alignment.
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
landscape
{
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
true
}
else
{
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
opened
?
true
:
hide
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
true
==
self
?
.
opened
?
true
:
hide
}
})
}
}
...
...
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