Skip to content

Commit 69b1607

Browse files
author
Alexander Perechnev
committed
Merge branch 'release/2.1'
2 parents 4e5dadc + d535c8a commit 69b1607

5 files changed

Lines changed: 44 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.1
2+
3+
* Now the top view controller is covered by transparent view when sidebar appears
4+
15
# 2.0.3
26

37
* `UIViewController` class extension moved to a new file and fully documented

SidebarOverlay.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Pod::Spec.new do |s|
22
s.name = "SidebarOverlay"
3-
s.version = "2.0.3"
3+
s.version = "2.1"
44
s.summary = "Yet another implementation of sidebar menu, but here your menu appears over the top view controller."
55

66
s.description = "Yet another implementation of sidebar menu, but here your menu appears over the top view controller. You questions and pull requests are wolcome."
77

88
s.homepage = "https://github.com/alexkrzyzanowski/SidebarOverlay"
99
s.license = { :type => 'MIT', :file => 'LICENSE' }
1010
s.author = { "Alex Krzyzanowski" => "alexkrzyzanowski@icloud.com" }
11-
s.source = { :git => "https://github.com/alexkrzyzanowski/SidebarOverlay.git", :tag => "2.0.3" }
11+
s.source = { :git => "https://github.com/alexkrzyzanowski/SidebarOverlay.git", :tag => "2.1" }
1212

1313
s.platform = :ios, '8.0'
1414
s.source_files = 'SidebarOverlay/SidebarOverlay/*.{h,m,swift}'

SidebarOverlay/SidebarOverlay/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.3</string>
18+
<string>2.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

SidebarOverlay/SidebarOverlay/SOContainerViewController.swift

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,36 @@ public class SOContainerViewController: UIViewController, UIGestureRecognizerDel
101101

102102
let animations = { () -> () in
103103
leftVC.view.frame = frame
104+
self.contentCoverView.alpha = newValue ? 1.0 : 0.0
104105
}
105106

106107
UIView.animateWithDuration(SideViewControllerOpenAnimationDuration, delay: 0, options: UIViewAnimationOptions.BeginFromCurrentState, animations: animations, completion: nil)
107108
}
108109
}
109110

111+
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
112+
self.contentCoverView = UIView()
113+
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
114+
}
115+
116+
public required init?(coder aDecoder: NSCoder) {
117+
self.contentCoverView = UIView()
118+
super.init(coder: aDecoder)
119+
}
120+
121+
public override func viewDidLoad() {
122+
super.viewDidLoad()
123+
124+
self.contentCoverView.frame = self.view.bounds
125+
self.contentCoverView.backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.5)
126+
self.contentCoverView.alpha = 0.0
127+
128+
let tapOnContentCoverViewGesture = UITapGestureRecognizer(target: self, action: "contentCoverViewClicked")
129+
self.contentCoverView.addGestureRecognizer(tapOnContentCoverViewGesture)
130+
131+
self.view.addSubview(self.contentCoverView)
132+
}
133+
110134
//
111135
// MARK: Gesture recognizer delegate
112136

@@ -126,6 +150,11 @@ public class SOContainerViewController: UIViewController, UIGestureRecognizerDel
126150
var _topViewController: UIViewController?
127151
var _leftViewController: UIViewController?
128152

153+
var contentCoverView: UIView
154+
155+
func contentCoverViewClicked() {
156+
self.isLeftViewControllerPresented = false
157+
}
129158

130159
func moveMenu(panGesture: UIPanGestureRecognizer) {
131160
panGesture.view?.layer.removeAllAnimations()
@@ -138,15 +167,20 @@ public class SOContainerViewController: UIViewController, UIGestureRecognizerDel
138167
}
139168

140169
panGesture.setTranslation(CGPointMake(0, 0), inView: self.view)
141-
}
142-
else if panGesture.state == UIGestureRecognizerState.Ended {
170+
171+
if let view = self.leftViewController?.view {
172+
self.contentCoverView.alpha = 1.0 - abs(view.frame.origin.x) / view.frame.size.width
173+
}
174+
} else if panGesture.state == UIGestureRecognizerState.Ended {
143175
if let sidebar = self.leftViewController {
144176
self.isLeftViewControllerPresented = self.viewPulledOutMoreThanHalfOfItsWidth(sidebar)
145177
}
146178
}
147179
}
148180

149181
func brindLeftViewToFront() {
182+
self.view.bringSubviewToFront(self.contentCoverView)
183+
150184
if let vc = self.leftViewController {
151185
self.view.bringSubviewToFront(vc.view)
152186
}

SidebarOverlayExample/SidebarOverlayExample/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.2</string>
18+
<string>2.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)