Commit 1dc2815d by Daniel Dahan

added comments and reworked SideNavigationViewController to fix issue 102

parent 8d3872d1
......@@ -13,8 +13,6 @@
9642FA251C1B50E700022BC6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */; };
9642FA311C1B906600022BC6 /* BMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA301C1B906600022BC6 /* BMainViewController.swift */; };
9642FA331C1B909700022BC6 /* SideViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA321C1B909700022BC6 /* SideViewController.swift */; };
96668B1C1C29C8F5001916C7 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96668B1B1C29C8F5001916C7 /* MaterialKit.framework */; };
96668B1D1C29C8F5001916C7 /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96668B1B1C29C8F5001916C7 /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -24,7 +22,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96668B1D1C29C8F5001916C7 /* MaterialKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -40,7 +37,6 @@
9642FA261C1B50E700022BC6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9642FA301C1B906600022BC6 /* BMainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BMainViewController.swift; sourceTree = "<group>"; };
9642FA321C1B909700022BC6 /* SideViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideViewController.swift; sourceTree = "<group>"; };
96668B1B1C29C8F5001916C7 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-anypxbsecgdqqxevbavirvnffqxd/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -48,7 +44,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96668B1C1C29C8F5001916C7 /* MaterialKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -58,7 +53,6 @@
9642FA0E1C1B50E700022BC6 = {
isa = PBXGroup;
children = (
96668B1B1C29C8F5001916C7 /* MaterialKit.framework */,
9642FA191C1B50E700022BC6 /* SideNavigationViewController */,
9642FA181C1B50E700022BC6 /* Products */,
);
......
......@@ -19,7 +19,7 @@
import UIKit
import MaterialKit
class SideViewController: UIViewController {
class SideViewController: UIViewController, SideNavigationViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
......
Pod::Spec.new do |s|
s.name = 'MK'
s.version = '1.25.8'
s.version = '1.26.0'
s.license = { :type => "AGPL-3.0", :file => "LICENSE" }
s.summary = 'A beautiful Material Design framework in Swift.'
s.homepage = 'http://materialkit.io'
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.25.8</string>
<string>1.26.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -20,7 +20,9 @@ import UIKit
public extension UIViewController {
/**
:name: sideNavigationViewController
A convenience property that provides access to the SideNavigationViewController.
This is the recommended method of accessing the SideNavigationViewController
through child UIViewControllers.
*/
public var sideNavigationViewController: SideNavigationViewController? {
var viewController: UIViewController? = self
......@@ -34,45 +36,53 @@ public extension UIViewController {
}
}
@objc(SideNavigationViewDelegate)
public protocol SideNavigationViewDelegate {
@objc(SideNavigationViewControllerDelegate)
public protocol SideNavigationViewControllerDelegate {
/**
:name: sideNavigationViewWillOpen
An optional delegation method that is fired before the
SideNavigationViewController opens.
*/
optional func sideNavigationViewWillOpen(sideNavigationViewController: SideNavigationViewController)
/**
:name: sideNavigationViewDidOpen
An optional delegation method that is fired after the
SideNavigationViewController opened.
*/
optional func sideNavigationViewDidOpen(sideNavigationViewController: SideNavigationViewController)
/**
:name: sideNavigationViewWillClose
An optional delegation method that is fired before the
SideNavigationViewController closes.
*/
optional func sideNavigationViewWillClose(sideNavigationViewController: SideNavigationViewController)
/**
:name: sideNavigationViewDidClose
An optional delegation method that is fired after the
SideNavigationViewController closed.
*/
optional func sideNavigationViewDidClose(sideNavigationViewController: SideNavigationViewController)
/**
:name: sideNavigationViewPanDidBegin
An optional delegation method that is fired when the
SideNavigationViewController pan gesture begins.
*/
optional func sideNavigationViewPanDidBegin(sideNavigationViewController: SideNavigationViewController, point: CGPoint)
/**
:name: sideNavigationViewPanDidChange
An optional delegation method that is fired when the
SideNavigationViewController pan gesture changes position.
*/
optional func sideNavigationViewPanDidChange(sideNavigationViewController: SideNavigationViewController, point: CGPoint)
/**
:name: sideNavigationViewPanDidEnd
An optional delegation method that is fired when the
SideNavigationViewController pan gesture ends.
*/
optional func sideNavigationViewPanDidEnd(sideNavigationViewController: SideNavigationViewController, point: CGPoint)
/**
:name: sideNavigationViewDidTap
An optional delegation method that is fired when the
SideNavigationViewController tap gesture begins.
*/
optional func sideNavigationViewDidTap(sideNavigationViewController: SideNavigationViewController, point: CGPoint)
}
......@@ -80,27 +90,50 @@ public protocol SideNavigationViewDelegate {
@objc(SideNavigationViewController)
public class SideNavigationViewController: UIViewController, UIGestureRecognizerDelegate {
/**
:name: originalPosition
A CGPoint property that is used internally to track
the original position of the sideView when panning began.
*/
private lazy var originalPosition: CGPoint = CGPointZero
private var originalPosition: CGPoint = CGPointZero
/**
:name: sidePanGesture
A UIPanGestureRecognizer property internally used for the
pan gesture.
*/
private var sidePanGesture: UIPanGestureRecognizer?
/**
:name: sideTapGesture
A UITapGestureRecognizer property internally used for the
tap gesture.
*/
private var sideTapGesture: UITapGestureRecognizer?
/**
:name: delegate
A CAShapeLayer property that is used as the backdrop when
opened. To change the opacity and color of the backdrop,
it is recommended to use the backdropOpcaity property and
backdropColor property, respectively.
*/
public weak var delegate: SideNavigationViewDelegate?
public private(set) lazy var backdropLayer: CAShapeLayer = CAShapeLayer()
/**
A CGFloat property that accesses the horizontal threshold of
the SideNavigationViewController. When the panning gesture has
ended, if the position is beyond the horizontal threshold,
the sideView is opened, if it is below the threshold, the
sideView is closed. The horizontal threshold is always at half
the width of the sideView.
*/
public private(set) var horizontalThreshold: CGFloat = 0
/**
A SideNavigationViewControllerDelegate property used to bind
the delegation object.
*/
public weak var delegate: SideNavigationViewControllerDelegate?
/**
:name: userInteractionEnabled
A Boolean property used to enable and disable interactivity
with the mainViewController.
*/
public var userInteractionEnabled: Bool {
get {
......@@ -112,69 +145,44 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: horizontalThreshold
*/
public lazy var horizontalThreshold: CGFloat = 0
/**
:name: animationDuration
A CGFloat property that sets the animation duration of the
sideView when closing and opening. Defaults to 0.25.
*/
public lazy var animationDuration: CGFloat = 0.25
public var animationDuration: CGFloat = 0.25
/**
:name: enabled
A Boolean property that enables and disables the sideView from
opening and closing. Defaults to true.
*/
public lazy var enabled: Bool = true
/**
:name: hideStatusBar
*/
public lazy var hideStatusBar: Bool = true
/**
:name: depthEnabled
*/
public var depthEnabled: Bool = true {
didSet {
if !depthEnabled {
sideView.depth = .None
}
}
}
public var enabled: Bool = true
/**
:name: depth
A Boolean property that triggers the status bar to be hidden
when the sideView is opened. Defaults to true.
*/
public var depth: MaterialDepth = .Depth2 {
didSet {
if !depthEnabled && .None != sideView.depth {
sideView.depth = depth
}
}
}
public var hideStatusBar: Bool = true
/**
:name: backdropLayer
A MaterialDepth property that is used to set the depth of the
sideView when opened.
*/
public private(set) lazy var backdropLayer: CAShapeLayer = CAShapeLayer()
public var depth: MaterialDepth = .Depth2
/**
:name: sideView
A MaterialView property that is used to hide and reveal the
sideViewController. It is very rare that this property will
need to be accessed externally.
*/
public private(set) var sideView: MaterialView!
/**
:name: backdropOpacity
*/
/// A CGFloat property to set the backdropLayer color opacity.
public var backdropOpacity: CGFloat = 0.5 {
didSet {
backdropLayer.backgroundColor = backdropColor?.colorWithAlphaComponent(backdropOpacity).CGColor
}
}
/**
:name: backdropColor
*/
/// A UIColor property to set the backdropLayer color.
public var backdropColor: UIColor? {
didSet {
backdropLayer.backgroundColor = backdropColor?.colorWithAlphaComponent(backdropOpacity).CGColor
......@@ -182,55 +190,73 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: opened
A Boolean property that indicates whether the sideView
is opened.
*/
public var opened: Bool {
return sideView.x != -sideViewControllerWidth
return sideView.x != -sideViewWidth
}
/**
:name: mainViewController
A UIViewController property that references the active
main UIViewController. To swap the mainViewController, it
is recommended to use the transitionFromMainViewController
helper method.
*/
public private(set) var mainViewController: UIViewController!
/**
:name: sideViewController
A UIViewController property that references the
active side UIViewController.
*/
public private(set) var sideViewController: UIViewController!
/**
:name: sideViewControllerWidth
A CGFloat property to access the width the sideView
opens up to.
*/
public private(set) var sideViewControllerWidth: CGFloat = 240
public private(set) var sideViewWidth: CGFloat = 240
/**
:name: init
An initializer for the SideNavigationViewController.
- Parameter mainViewController: The main UIViewController.
- Parameter sideViewController: The side UIViewController.
*/
public convenience init(mainViewController: UIViewController, sideViewController: UIViewController) {
self.init()
self.mainViewController = mainViewController
self.sideViewController = sideViewController
prepareView()
prepareMainViewController()
prepareSideView()
}
/**
:name: viewWillLayoutSubviews
*/
public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
layoutBackdropLayer()
horizontalThreshold = sideViewControllerWidth / 2
sideView.width = sideViewControllerWidth
sideView.height = view.bounds.height
MaterialAnimation.animationDisabled { [unowned self] in
self.backdropLayer.frame = self.view.bounds
self.sideView.width = self.sideViewWidth
self.sideView.height = self.view.bounds.height
}
horizontalThreshold = sideViewWidth / 2
sideViewController.view.frame.size.width = sideView.width
sideViewController.view.frame.size.height = sideView.height
sideViewController.view.center = CGPointMake(sideView.width / 2, sideView.height / 2)
}
/**
:name: transitionFromMainViewController
A method to swap mainViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active mainViewController.
- Parameter duration: A NSTimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active mainViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active mainViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active mainViewController
to the toViewController has completed.
*/
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval, options: UIViewAnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?) {
mainViewController.willMoveToParentViewController(nil)
......@@ -251,12 +277,18 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: setSideViewControllerWidth
A method that is used to set the width of the sideView when
opened. This is the recommended method of setting the sideView
width.
- Parameter width: A CGFloat value to set as the new width.
- Parameter hidden: A Boolean value of whether the sideView
should be hidden after the width has been updated or not.
- Parameter animated: A Boolean value that indicates to animate
the sideView width change.
*/
public func setSideViewControllerWidth(width: CGFloat, hidden: Bool, animated: Bool) {
sideViewControllerWidth = width
public func setSideViewWidth(width: CGFloat, hidden: Bool, animated: Bool) {
let w: CGFloat = (hidden ? -width : width) / 2
sideViewWidth = width
if animated {
MaterialAnimation.animateWithDuration(0.25, animations: { [unowned self] in
......@@ -274,14 +306,21 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: toggle
A method that toggles the sideView opened if previously closed,
or closed if previously opened.
- Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the
sideView. Defaults to 0.
*/
public func toggle(velocity: CGFloat = 0) {
opened ? close(velocity) : open(velocity)
}
/**
:name: open
A method that opens the sideView.
- Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the
sideView. Defaults to 0.
*/
public func open(velocity: CGFloat = 0) {
toggleStatusBar(true)
......@@ -294,19 +333,16 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
self.sideView.position = CGPointMake(self.sideView.width / 2, self.sideView.height / 2)
}) { [unowned self] in
self.userInteractionEnabled = false
if self.depthEnabled {
MaterialAnimation.animationDisabled { [unowned self] in
self.sideView.depth = self.depth
}
}
self.showSideViewDepth()
self.delegate?.sideNavigationViewDidOpen?(self)
}
}
/**
:name: close
A method that closes the sideView.
- Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the
sideView. Defaults to 0.
*/
public func close(velocity: CGFloat = 0) {
toggleStatusBar(false)
......@@ -319,24 +355,15 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
self.sideView.position = CGPointMake(-self.sideView.width / 2, self.sideView.height / 2)
}) { [unowned self] in
self.userInteractionEnabled = true
if self.depthEnabled {
MaterialAnimation.animationDisabled { [unowned self] in
self.sideView.depth = .None
}
}
self.hideSideViewDepth()
self.delegate?.sideNavigationViewDidClose?(self)
}
}
/**
:name: gestureRecognizer
*/
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
if enabled {
if gestureRecognizer == sidePanGesture {
return gesturePanSideViewController(gestureRecognizer, withTouchPoint: touch.locationInView(view))
return opened || enabled && isPointContainedWithinRect(touch.locationInView(view))
}
if opened && gestureRecognizer == sideTapGesture {
let point: CGPoint = touch.locationInView(view)
......@@ -348,48 +375,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: prepareView
*/
public func prepareView() {
prepareBackdropLayer()
}
/**
:name: prepareMainViewController
*/
internal func prepareMainViewController() {
prepareViewControllerWithinContainer(mainViewController, container: view)
mainViewController.view.frame = view.bounds
}
/**
:name: prepareSideViewController
*/
internal func prepareSideViewController() {
sideViewController.view.clipsToBounds = true
prepareViewControllerWithinContainer(sideViewController, container: sideView)
}
/**
:name: prepareSideView
*/
internal func prepareSideView() {
sideView = MaterialView()
sideView.frame = CGRectMake(0, 0, sideViewControllerWidth, view.frame.height)
sideView.backgroundColor = MaterialColor.clear
view.addSubview(sideView)
MaterialAnimation.animationDisabled { [unowned self] in
self.sideView.position.x = -self.sideViewControllerWidth / 2
self.sideView.zPosition = 1000
}
prepareSideViewController()
prepareGestures()
}
/**
:name: handlePanGesture
A method that is fired when the pan gesture is recognized
for the SideNavigationViewController.
- Parameter recognizer: A UIPanGestureRecognizer that is
passed to the handler when recognized.
*/
internal func handlePanGesture(recognizer: UIPanGestureRecognizer) {
switch recognizer.state {
......@@ -397,11 +386,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
backdropLayer.hidden = false
originalPosition = sideView.position
toggleStatusBar(true)
if depthEnabled {
MaterialAnimation.animationDisabled { [unowned self, sideView = self.sideView] in
sideView.depth = self.depth
}
}
showSideViewDepth()
delegate?.sideNavigationViewPanDidBegin?(self, point: sideView.position)
case .Changed:
let translation: CGPoint = recognizer.translationInView(sideView)
......@@ -417,7 +402,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
delegate?.sideNavigationViewPanDidEnd?(self, point: sideView.position)
if sideView.x <= CGFloat(floor(-sideViewControllerWidth)) + horizontalThreshold || point.x <= -1000 {
if sideView.x <= CGFloat(floor(-sideViewWidth)) + horizontalThreshold || point.x <= -1000 {
close(x)
} else {
open(x)
......@@ -427,16 +412,96 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: handleTapGesture
A method that is fired when the tap gesture is recognized
for the SideNavigationViewController.
- Parameter recognizer: A UITapGestureRecognizer that is
passed to the handler when recognized.
*/
internal func handleTapGesture(recognizer: UIPanGestureRecognizer) {
internal func handleTapGesture(recognizer: UITapGestureRecognizer) {
if opened {
close()
}
}
/**
:name: prepareGestures
A method that generally prepares the SideNavigationViewController.
*/
private func prepareView() {
prepareBackdropLayer()
prepareMainViewController()
prepareSideView()
}
/**
A method that prepares the mainViewController.
*/
private func prepareMainViewController() {
prepareViewControllerWithinContainer(mainViewController, container: view)
mainViewController.view.frame = view.bounds
}
/**
A method that prepares the sideViewController.
*/
private func prepareSideViewController() {
sideViewController.view.clipsToBounds = true
prepareViewControllerWithinContainer(sideViewController, container: sideView)
}
/**
A method that prepares the sideView.
*/
private func prepareSideView() {
sideView = MaterialView()
sideView.frame = CGRectMake(0, 0, sideViewWidth, view.frame.height)
sideView.backgroundColor = MaterialColor.clear
view.addSubview(sideView)
MaterialAnimation.animationDisabled { [unowned self] in
self.sideView.position.x = -self.sideViewWidth / 2
self.sideView.zPosition = 1000
}
prepareSideViewController()
removeGestures(&sidePanGesture, tap: &sideTapGesture)
prepareGestures(&sidePanGesture, panSelector: "handlePanGesture:", tap: &sideTapGesture, tapSelector: "handleTapGesture:")
}
/**
A method that prepares the backdropLayer.
*/
private func prepareBackdropLayer() {
backdropColor = MaterialColor.black
backdropLayer.zPosition = 900
backdropLayer.hidden = true
view.layer.addSublayer(backdropLayer)
}
/**
A method that adds the passed in controller as a child of
the SideNavigationViewController within the passed in
container view.
- Parameter controller: A UIViewController to add as a child.
- Parameter container: A UIView that is the parent of the
passed in controller view within the view hierarchy.
*/
private func prepareViewControllerWithinContainer(controller: UIViewController, container: UIView) {
addChildViewController(controller)
container.addSubview(controller.view)
controller.didMoveToParentViewController(self)
}
/**
A method that prepares the gestures used within the
SideNavigationViewController.
- Parameter pan: A UIPanGestureRecognizer that is used to
recognize pan gestures.
- Parameter panSelector: A Selector that is fired when the
pan gesture is recognized.
- Parameter tap: A UITapGestureRecognizer that is used to
recognize tap gestures.
- Parameter tapSelector: A Selector that is fired when the
tap gesture is recognized.
*/
private func prepareGestures(inout pan: UIPanGestureRecognizer?, panSelector: Selector, inout tap: UITapGestureRecognizer?, tapSelector: Selector) {
if nil == pan {
......@@ -452,7 +517,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: removeGestures
A method that removes the passed in pan and tap gesture
recognizers.
- Parameter pan: A UIPanGestureRecognizer that should be
removed from the SideNavigationViewController.
- Parameter tap: A UITapGestureRecognizer that should be
removed from the SideNavigationViewController.
*/
private func removeGestures(inout pan: UIPanGestureRecognizer?, inout tap: UITapGestureRecognizer?) {
if let v: UIPanGestureRecognizer = pan {
......@@ -466,7 +536,11 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: toggleStatusBar
A method to toggle the status bar from a reveal state to
hidden state. The hideStatusBar property needs to be set
to true in order for this method to have any affect.
- Parameter hide: A Boolean indicating to show or hide
the status bar.
*/
private func toggleStatusBar(hide: Bool = false) {
if hideStatusBar {
......@@ -475,68 +549,48 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: removeViewController
*/
private func removeViewController(controller: UIViewController) {
controller.willMoveToParentViewController(nil)
controller.view.removeFromSuperview()
controller.removeFromParentViewController()
}
/**
:name: gesturePanSideViewController
*/
private func gesturePanSideViewController(gesture: UIGestureRecognizer, withTouchPoint point: CGPoint) -> Bool {
return opened || enabled && isLeftPointContainedWithinRect(point)
}
/**
:name: isLeftPointContainedWithinRect
A method that determines whether the passed point is
contained within the bounds of the horizontalThreshold
and height of the SideNavigationViewController view frame
property.
- Parameter point: A CGPoint to test against.
- Returns: A Boolean of the result, true if yes, false
otherwise.
*/
private func isLeftPointContainedWithinRect(point: CGPoint) -> Bool {
private func isPointContainedWithinRect(point: CGPoint) -> Bool {
return CGRectContainsPoint(CGRectMake(0, 0, horizontalThreshold, view.frame.height), point)
}
/**
:name: isPointContainedWithinViewController
A method that determines whether the passed in point is
contained within the bounds of the passed in container view.
- Parameter container: A UIView that sets the bounds to test
against.
- Parameter point: A CGPoint to test whether or not it is
within the bounds of the container parameter.
- Returns: A Boolean of the result, true if yes, false
otherwise.
*/
private func isPointContainedWithinViewController(container: UIView, point: CGPoint) -> Bool {
return CGRectContainsPoint(container.frame, point)
}
/**
:name: prepareBackdropLayer
A method that adds the depth to the sideView depth property.
*/
private func prepareBackdropLayer() {
backdropColor = MaterialColor.black
backdropLayer.zPosition = 900
backdropLayer.hidden = true
view.layer.addSublayer(backdropLayer)
}
/**
:name: layoutBackdropLayer
*/
private func layoutBackdropLayer() {
private func showSideViewDepth() {
MaterialAnimation.animationDisabled { [unowned self] in
self.backdropLayer.frame = self.view.bounds
self.sideView.depth = self.depth
}
}
/**
:name: prepareViewControllerWithinContainer
A method that removes the depth from the sideView depth
property.
*/
private func prepareViewControllerWithinContainer(controller: UIViewController, container: UIView) {
addChildViewController(controller)
container.addSubview(controller.view)
controller.didMoveToParentViewController(self)
}
/**
:name: prepareGestures
*/
private func prepareGestures() {
removeGestures(&sidePanGesture, tap: &sideTapGesture)
prepareGestures(&sidePanGesture, panSelector: "handlePanGesture:", tap: &sideTapGesture, tapSelector: "handleTapGesture:")
private func hideSideViewDepth() {
MaterialAnimation.animationDisabled { [unowned self] in
self.sideView.depth = .None
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment