Skip to content

Commit

Permalink
Hotfix custom menu is not deallocated issue
Browse files Browse the repository at this point in the history
  • Loading branch information
luannguyenkhoa-agilityio committed Dec 25, 2018
1 parent a09d371 commit f4d5056
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion LNSideMenu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'LNSideMenu'
s.version = '3.4.2'
s.version = '3.4.3'
s.summary = 'A side menu control for iOS in Swift with custom layer and scrolling effect. Right and Left sides. iOS 8+.'

# This description is used to generate tags and improve search results.
Expand Down
18 changes: 10 additions & 8 deletions LNSideMenu/Classes/LNSideMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public final class LNSideMenu: NSObject {
public var animationDuration = 0.5
public var hideWhenDidSelectOnCell = true
public var items = [String]()
public var blurColor = UIColor.gray.withAlphaComponent(0.5)
// uidynamic behavior, set false to disable it
public var enableDynamic: Bool = false {
didSet {
Expand Down Expand Up @@ -92,16 +93,19 @@ public final class LNSideMenu: NSObject {
fileprivate lazy var blurView: UIView = {
return self.initialBlurView()
}()
fileprivate var navController: UINavigationController?


// MARK: Initialize

fileprivate init(sourceView source: UIView, position: Position) {
fileprivate init(sourceView source: UIView, position: Position, isBlur: Bool = false) {
super.init()
sourceView = source
self.position = position

/// Adding blur if needed
if isBlur {
source.addSubview(blurView)
}

/*
A dynamic animator provides physics-related capabilities and animations for its dynamic items, and provides the context for those animations.
It does this by intermediating between the underlying iOS physics engine and dynamic items, via behavior objects you add to the animator.
Expand Down Expand Up @@ -172,10 +176,9 @@ public final class LNSideMenu: NSObject {

// Initialize side menu without using default menu, using your own custom sidemenu instead
public convenience init(navigation nav: UINavigationController, menuPosition: Position, customSideMenu: UIViewController, size: LNSize = .twothird) {
self.init(sourceView: nav.view, position: menuPosition)
self.init(sourceView: nav.view, position: menuPosition, isBlur: true)
// Keep references
customMenu = customSideMenu
navController = nav

// Config custom menu view
customMenu?.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
Expand All @@ -193,9 +196,8 @@ public final class LNSideMenu: NSObject {
fileprivate func initialBlurView() -> UIView {
// Add blur view for custom sidemenu
let blurView = UIView(frame: sideMenuContainerView.bounds)
blurView.backgroundColor = UIColor.gray.withAlphaComponent(0.5)
blurView.backgroundColor = blurColor
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
navController?.navigationBar.addSubview(blurView)
return blurView
}

Expand Down Expand Up @@ -492,7 +494,7 @@ public final class LNSideMenu: NSObject {
, y: ypos, width: width, height: height)
// Update blur view y position
if isCustomMenu {
blurView.y = ypos - 20
blurView.frame = CGRect(x: 0, y: ypos - 20, width: sideMenuContainerView.width, height: sideMenuContainerView.height + abs(ypos - 20))
}
}

Expand Down

0 comments on commit f4d5056

Please sign in to comment.