├── DrawerMenu ├── DrawerController.swift ├── MenuViewController.swift └── RootViewController.swift ├── DrawerMenuExample ├── DrawerMenuExample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ ├── Florian.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── duybui.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── Florian.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── duybui.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── DrawerMenuExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── hamburger-menu-icon.imageset │ │ ├── Contents.json │ │ ├── hamburger-menu-icon-1.png │ │ ├── hamburger-menu-icon-2.png │ │ └── hamburger-menu-icon.png │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── LICENSE └── README.md /DrawerMenu/DrawerController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DrawerController.swift 3 | // iosapptemplates.com 4 | // 5 | // Created by Florian Marcu on 1/17/18. 6 | // Copyright © 2018 iOS App Templates. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DrawerController: UIViewController, RootViewControllerDelegate { 12 | var rootViewController: RootViewController 13 | var menuController: MenuViewController 14 | var isMenuExpanded: Bool = false 15 | let overlayView = UIView() 16 | 17 | init(rootViewController: RootViewController, menuController: MenuViewController) { 18 | self.rootViewController = rootViewController 19 | self.menuController = menuController 20 | super.init(nibName: nil, bundle: nil) 21 | self.rootViewController.drawerDelegate = self 22 | } 23 | 24 | required public init?(coder aDecoder: NSCoder) { 25 | fatalError("init(coder:) has not been implemented") 26 | } 27 | 28 | override func viewDidLoad() { 29 | super.viewDidLoad() 30 | 31 | self.addChild(rootViewController) 32 | self.view.addSubview(rootViewController.view) 33 | rootViewController.didMove(toParent: self) 34 | 35 | overlayView.backgroundColor = .black 36 | overlayView.alpha = 0 37 | view.addSubview(overlayView) 38 | 39 | self.menuController.view.frame = CGRect(x: 0, y: 0, width: 0, height: self.view.bounds.height) 40 | self.addChild(menuController) 41 | self.view.addSubview(menuController.view) 42 | menuController.didMove(toParent: self) 43 | 44 | configureGestures() 45 | } 46 | 47 | override func viewDidLayoutSubviews() { 48 | super.viewDidLayoutSubviews() 49 | overlayView.frame = view.bounds 50 | let width: CGFloat = (isMenuExpanded) ? view.bounds.width * 2 / 3 : 0.0 51 | self.menuController.view.frame = CGRect(x: 0, y: 0, width: width , height: self.view.bounds.height) 52 | } 53 | 54 | func toggleMenu() { 55 | isMenuExpanded = !isMenuExpanded 56 | let bounds = self.view.bounds 57 | let width: CGFloat = (isMenuExpanded) ? bounds.width * 2 / 3 : 0.0 58 | 59 | UIView.animate(withDuration: 0.3, animations: { 60 | self.menuController.view.frame = CGRect(x: 0, y: 0, width: width, height: bounds.height) 61 | self.overlayView.alpha = (self.isMenuExpanded) ? 0.5 : 0.0 62 | }) { (success) in 63 | } 64 | } 65 | 66 | func navigateTo(viewController: UIViewController) { 67 | rootViewController.setViewControllers([viewController], animated: true) 68 | self.toggleMenu() 69 | } 70 | 71 | fileprivate func configureGestures() { 72 | let swipeLeftGesture = UISwipeGestureRecognizer(target: self, action: #selector(didSwipeLeft)) 73 | swipeLeftGesture.direction = .left 74 | overlayView.addGestureRecognizer(swipeLeftGesture) 75 | 76 | let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapOverlay)) 77 | overlayView.addGestureRecognizer(tapGesture) 78 | } 79 | 80 | @objc fileprivate func didSwipeLeft() { 81 | toggleMenu() 82 | } 83 | 84 | @objc fileprivate func didTapOverlay() { 85 | toggleMenu() 86 | } 87 | } 88 | 89 | extension DrawerController { 90 | func rootViewControllerDidTapMenuButton(_ rootViewController: RootViewController) { 91 | toggleMenu() 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /DrawerMenu/MenuViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuViewController.swift 3 | // DrawerMenuExample 4 | // 5 | // Created by Florian Marcu on 1/17/18. 6 | // Copyright © 2018 iOS App Templates. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MenuViewController: UIViewController { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /DrawerMenu/RootViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.swift 3 | // DrawerMenuExample 4 | // 5 | // Created by Florian Marcu on 1/17/18. 6 | // Copyright © 2018 iOS App Templates. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol RootViewControllerDelegate: class { 12 | func rootViewControllerDidTapMenuButton(_ rootViewController: RootViewController) 13 | } 14 | 15 | class RootViewController: UINavigationController, UINavigationControllerDelegate { 16 | fileprivate var menuButton: UIBarButtonItem! 17 | fileprivate var topNavigationLeftImage: UIImage? 18 | weak var drawerDelegate: RootViewControllerDelegate? 19 | 20 | public init(mainViewController: UIViewController, topNavigationLeftImage: UIImage?) { 21 | super.init(rootViewController: mainViewController) 22 | self.topNavigationLeftImage = topNavigationLeftImage 23 | menuButton = UIBarButtonItem(image: topNavigationLeftImage, style: .plain, target: self, action: #selector(handleMenuButton)) 24 | } 25 | 26 | public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { 27 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 28 | } 29 | 30 | required public init?(coder aDecoder: NSCoder) { 31 | fatalError("init(coder:) has not been implemented") 32 | } 33 | 34 | override public func viewDidLoad() { 35 | super.viewDidLoad() 36 | self.delegate = self 37 | } 38 | 39 | public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { 40 | prepareNavigationBar() 41 | } 42 | } 43 | 44 | extension RootViewController { 45 | fileprivate func prepareNavigationBar() { 46 | topViewController?.navigationItem.title = topViewController?.title 47 | if self.viewControllers.count <= 1 { 48 | topViewController?.navigationItem.leftBarButtonItem = menuButton 49 | } 50 | } 51 | } 52 | 53 | extension RootViewController { 54 | @objc 55 | fileprivate func handleMenuButton() { 56 | drawerDelegate?.rootViewControllerDidTapMenuButton(self) 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 178F78CC2010251400CFFF71 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178F78CB2010251400CFFF71 /* AppDelegate.swift */; }; 11 | 178F78CE2010251400CFFF71 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178F78CD2010251400CFFF71 /* ViewController.swift */; }; 12 | 178F78D12010251400CFFF71 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 178F78CF2010251400CFFF71 /* Main.storyboard */; }; 13 | 178F78D32010251400CFFF71 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 178F78D22010251400CFFF71 /* Assets.xcassets */; }; 14 | 178F78D62010251400CFFF71 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 178F78D42010251400CFFF71 /* LaunchScreen.storyboard */; }; 15 | 178F78DF2010252700CFFF71 /* DrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178F78DE2010252700CFFF71 /* DrawerController.swift */; }; 16 | 178F78E12010257600CFFF71 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178F78E02010257600CFFF71 /* RootViewController.swift */; }; 17 | 178F78E3201025FD00CFFF71 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178F78E2201025FD00CFFF71 /* MenuViewController.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 178F78C82010251400CFFF71 /* DrawerMenuExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DrawerMenuExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 178F78CB2010251400CFFF71 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | 178F78CD2010251400CFFF71 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 24 | 178F78D02010251400CFFF71 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | 178F78D22010251400CFFF71 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 26 | 178F78D52010251400CFFF71 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 178F78D72010251400CFFF71 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 178F78DE2010252700CFFF71 /* DrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DrawerController.swift; sourceTree = ""; }; 29 | 178F78E02010257600CFFF71 /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = ""; }; 30 | 178F78E2201025FD00CFFF71 /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 178F78C52010251400CFFF71 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 178F78BF2010251400CFFF71 = { 45 | isa = PBXGroup; 46 | children = ( 47 | 178F78DD2010252700CFFF71 /* DrawerMenu */, 48 | 178F78CA2010251400CFFF71 /* DrawerMenuExample */, 49 | 178F78C92010251400CFFF71 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 178F78C92010251400CFFF71 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 178F78C82010251400CFFF71 /* DrawerMenuExample.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 178F78CA2010251400CFFF71 /* DrawerMenuExample */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 178F78CB2010251400CFFF71 /* AppDelegate.swift */, 65 | 178F78CD2010251400CFFF71 /* ViewController.swift */, 66 | 178F78CF2010251400CFFF71 /* Main.storyboard */, 67 | 178F78D22010251400CFFF71 /* Assets.xcassets */, 68 | 178F78D42010251400CFFF71 /* LaunchScreen.storyboard */, 69 | 178F78D72010251400CFFF71 /* Info.plist */, 70 | ); 71 | path = DrawerMenuExample; 72 | sourceTree = ""; 73 | }; 74 | 178F78DD2010252700CFFF71 /* DrawerMenu */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 178F78DE2010252700CFFF71 /* DrawerController.swift */, 78 | 178F78E02010257600CFFF71 /* RootViewController.swift */, 79 | 178F78E2201025FD00CFFF71 /* MenuViewController.swift */, 80 | ); 81 | name = DrawerMenu; 82 | path = ../DrawerMenu; 83 | sourceTree = ""; 84 | }; 85 | /* End PBXGroup section */ 86 | 87 | /* Begin PBXNativeTarget section */ 88 | 178F78C72010251400CFFF71 /* DrawerMenuExample */ = { 89 | isa = PBXNativeTarget; 90 | buildConfigurationList = 178F78DA2010251400CFFF71 /* Build configuration list for PBXNativeTarget "DrawerMenuExample" */; 91 | buildPhases = ( 92 | 178F78C42010251400CFFF71 /* Sources */, 93 | 178F78C52010251400CFFF71 /* Frameworks */, 94 | 178F78C62010251400CFFF71 /* Resources */, 95 | ); 96 | buildRules = ( 97 | ); 98 | dependencies = ( 99 | ); 100 | name = DrawerMenuExample; 101 | productName = DrawerMenuExample; 102 | productReference = 178F78C82010251400CFFF71 /* DrawerMenuExample.app */; 103 | productType = "com.apple.product-type.application"; 104 | }; 105 | /* End PBXNativeTarget section */ 106 | 107 | /* Begin PBXProject section */ 108 | 178F78C02010251400CFFF71 /* Project object */ = { 109 | isa = PBXProject; 110 | attributes = { 111 | LastSwiftUpdateCheck = 0920; 112 | LastUpgradeCheck = 1110; 113 | ORGANIZATIONNAME = "iOS App Templates"; 114 | TargetAttributes = { 115 | 178F78C72010251400CFFF71 = { 116 | CreatedOnToolsVersion = 9.2; 117 | ProvisioningStyle = Automatic; 118 | }; 119 | }; 120 | }; 121 | buildConfigurationList = 178F78C32010251400CFFF71 /* Build configuration list for PBXProject "DrawerMenuExample" */; 122 | compatibilityVersion = "Xcode 8.0"; 123 | developmentRegion = en; 124 | hasScannedForEncodings = 0; 125 | knownRegions = ( 126 | en, 127 | Base, 128 | ); 129 | mainGroup = 178F78BF2010251400CFFF71; 130 | productRefGroup = 178F78C92010251400CFFF71 /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | 178F78C72010251400CFFF71 /* DrawerMenuExample */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXResourcesBuildPhase section */ 140 | 178F78C62010251400CFFF71 /* Resources */ = { 141 | isa = PBXResourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 178F78D62010251400CFFF71 /* LaunchScreen.storyboard in Resources */, 145 | 178F78D32010251400CFFF71 /* Assets.xcassets in Resources */, 146 | 178F78D12010251400CFFF71 /* Main.storyboard in Resources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXResourcesBuildPhase section */ 151 | 152 | /* Begin PBXSourcesBuildPhase section */ 153 | 178F78C42010251400CFFF71 /* Sources */ = { 154 | isa = PBXSourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | 178F78CE2010251400CFFF71 /* ViewController.swift in Sources */, 158 | 178F78E3201025FD00CFFF71 /* MenuViewController.swift in Sources */, 159 | 178F78E12010257600CFFF71 /* RootViewController.swift in Sources */, 160 | 178F78CC2010251400CFFF71 /* AppDelegate.swift in Sources */, 161 | 178F78DF2010252700CFFF71 /* DrawerController.swift in Sources */, 162 | ); 163 | runOnlyForDeploymentPostprocessing = 0; 164 | }; 165 | /* End PBXSourcesBuildPhase section */ 166 | 167 | /* Begin PBXVariantGroup section */ 168 | 178F78CF2010251400CFFF71 /* Main.storyboard */ = { 169 | isa = PBXVariantGroup; 170 | children = ( 171 | 178F78D02010251400CFFF71 /* Base */, 172 | ); 173 | name = Main.storyboard; 174 | sourceTree = ""; 175 | }; 176 | 178F78D42010251400CFFF71 /* LaunchScreen.storyboard */ = { 177 | isa = PBXVariantGroup; 178 | children = ( 179 | 178F78D52010251400CFFF71 /* Base */, 180 | ); 181 | name = LaunchScreen.storyboard; 182 | sourceTree = ""; 183 | }; 184 | /* End PBXVariantGroup section */ 185 | 186 | /* Begin XCBuildConfiguration section */ 187 | 178F78D82010251400CFFF71 /* Debug */ = { 188 | isa = XCBuildConfiguration; 189 | buildSettings = { 190 | ALWAYS_SEARCH_USER_PATHS = NO; 191 | CLANG_ANALYZER_NONNULL = YES; 192 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 193 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 194 | CLANG_CXX_LIBRARY = "libc++"; 195 | CLANG_ENABLE_MODULES = YES; 196 | CLANG_ENABLE_OBJC_ARC = YES; 197 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 198 | CLANG_WARN_BOOL_CONVERSION = YES; 199 | CLANG_WARN_COMMA = YES; 200 | CLANG_WARN_CONSTANT_CONVERSION = YES; 201 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 202 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 203 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 204 | CLANG_WARN_EMPTY_BODY = YES; 205 | CLANG_WARN_ENUM_CONVERSION = YES; 206 | CLANG_WARN_INFINITE_RECURSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 209 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 210 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 211 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 212 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 213 | CLANG_WARN_STRICT_PROTOTYPES = YES; 214 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 215 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 216 | CLANG_WARN_UNREACHABLE_CODE = YES; 217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 218 | CODE_SIGN_IDENTITY = "iPhone Developer"; 219 | COPY_PHASE_STRIP = NO; 220 | DEBUG_INFORMATION_FORMAT = dwarf; 221 | ENABLE_STRICT_OBJC_MSGSEND = YES; 222 | ENABLE_TESTABILITY = YES; 223 | GCC_C_LANGUAGE_STANDARD = gnu11; 224 | GCC_DYNAMIC_NO_PIC = NO; 225 | GCC_NO_COMMON_BLOCKS = YES; 226 | GCC_OPTIMIZATION_LEVEL = 0; 227 | GCC_PREPROCESSOR_DEFINITIONS = ( 228 | "DEBUG=1", 229 | "$(inherited)", 230 | ); 231 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 232 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 233 | GCC_WARN_UNDECLARED_SELECTOR = YES; 234 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 235 | GCC_WARN_UNUSED_FUNCTION = YES; 236 | GCC_WARN_UNUSED_VARIABLE = YES; 237 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 238 | MTL_ENABLE_DEBUG_INFO = YES; 239 | ONLY_ACTIVE_ARCH = YES; 240 | SDKROOT = iphoneos; 241 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 242 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 243 | }; 244 | name = Debug; 245 | }; 246 | 178F78D92010251400CFFF71 /* Release */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ALWAYS_SEARCH_USER_PATHS = NO; 250 | CLANG_ANALYZER_NONNULL = YES; 251 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 252 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 253 | CLANG_CXX_LIBRARY = "libc++"; 254 | CLANG_ENABLE_MODULES = YES; 255 | CLANG_ENABLE_OBJC_ARC = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | CODE_SIGN_IDENTITY = "iPhone Developer"; 278 | COPY_PHASE_STRIP = NO; 279 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 280 | ENABLE_NS_ASSERTIONS = NO; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu11; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 291 | MTL_ENABLE_DEBUG_INFO = NO; 292 | SDKROOT = iphoneos; 293 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 294 | VALIDATE_PRODUCT = YES; 295 | }; 296 | name = Release; 297 | }; 298 | 178F78DB2010251400CFFF71 /* Debug */ = { 299 | isa = XCBuildConfiguration; 300 | buildSettings = { 301 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 302 | CODE_SIGN_STYLE = Automatic; 303 | DEVELOPMENT_TEAM = JSQ6T9Y6J4; 304 | INFOPLIST_FILE = DrawerMenuExample/Info.plist; 305 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 306 | PRODUCT_BUNDLE_IDENTIFIER = com.iosapptemplates.DrawerMenuExample; 307 | PRODUCT_NAME = "$(TARGET_NAME)"; 308 | SWIFT_VERSION = 5.0; 309 | TARGETED_DEVICE_FAMILY = "1,2"; 310 | }; 311 | name = Debug; 312 | }; 313 | 178F78DC2010251400CFFF71 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 317 | CODE_SIGN_STYLE = Automatic; 318 | DEVELOPMENT_TEAM = JSQ6T9Y6J4; 319 | INFOPLIST_FILE = DrawerMenuExample/Info.plist; 320 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 321 | PRODUCT_BUNDLE_IDENTIFIER = com.iosapptemplates.DrawerMenuExample; 322 | PRODUCT_NAME = "$(TARGET_NAME)"; 323 | SWIFT_VERSION = 5.0; 324 | TARGETED_DEVICE_FAMILY = "1,2"; 325 | }; 326 | name = Release; 327 | }; 328 | /* End XCBuildConfiguration section */ 329 | 330 | /* Begin XCConfigurationList section */ 331 | 178F78C32010251400CFFF71 /* Build configuration list for PBXProject "DrawerMenuExample" */ = { 332 | isa = XCConfigurationList; 333 | buildConfigurations = ( 334 | 178F78D82010251400CFFF71 /* Debug */, 335 | 178F78D92010251400CFFF71 /* Release */, 336 | ); 337 | defaultConfigurationIsVisible = 0; 338 | defaultConfigurationName = Release; 339 | }; 340 | 178F78DA2010251400CFFF71 /* Build configuration list for PBXNativeTarget "DrawerMenuExample" */ = { 341 | isa = XCConfigurationList; 342 | buildConfigurations = ( 343 | 178F78DB2010251400CFFF71 /* Debug */, 344 | 178F78DC2010251400CFFF71 /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | /* End XCConfigurationList section */ 350 | }; 351 | rootObject = 178F78C02010251400CFFF71 /* Project object */; 352 | } 353 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/project.xcworkspace/xcuserdata/Florian.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopebase/swift-drawer-menu/f4bb3003f5e5962c31da85d78c76270dd5fe6ba1/DrawerMenuExample/DrawerMenuExample.xcodeproj/project.xcworkspace/xcuserdata/Florian.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/project.xcworkspace/xcuserdata/duybui.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopebase/swift-drawer-menu/f4bb3003f5e5962c31da85d78c76270dd5fe6ba1/DrawerMenuExample/DrawerMenuExample.xcodeproj/project.xcworkspace/xcuserdata/duybui.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/xcuserdata/Florian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/xcuserdata/Florian.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DrawerMenuExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample.xcodeproj/xcuserdata/duybui.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DrawerMenuExample.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DrawerMenuExample 4 | // 5 | // Created by Florian Marcu on 1/17/18. 6 | // Copyright © 2018 iOS App Templates. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 15 | // Override point for customization after application launch. 16 | return true 17 | } 18 | 19 | func applicationWillResignActive(_ application: UIApplication) { 20 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 21 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 22 | } 23 | 24 | func applicationDidEnterBackground(_ application: UIApplication) { 25 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 26 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 27 | } 28 | 29 | func applicationWillEnterForeground(_ application: UIApplication) { 30 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 31 | } 32 | 33 | func applicationDidBecomeActive(_ application: UIApplication) { 34 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 35 | } 36 | 37 | func applicationWillTerminate(_ application: UIApplication) { 38 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 39 | } 40 | 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "hamburger-menu-icon-1.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "hamburger-menu-icon.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "hamburger-menu-icon-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/hamburger-menu-icon-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopebase/swift-drawer-menu/f4bb3003f5e5962c31da85d78c76270dd5fe6ba1/DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/hamburger-menu-icon-1.png -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/hamburger-menu-icon-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopebase/swift-drawer-menu/f4bb3003f5e5962c31da85d78c76270dd5fe6ba1/DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/hamburger-menu-icon-2.png -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/hamburger-menu-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopebase/swift-drawer-menu/f4bb3003f5e5962c31da85d78c76270dd5fe6ba1/DrawerMenuExample/DrawerMenuExample/Assets.xcassets/hamburger-menu-icon.imageset/hamburger-menu-icon.png -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DrawerMenuExample/DrawerMenuExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DrawerMenuExample 4 | // 5 | // Created by Florian Marcu on 1/17/18. 6 | // Copyright © 2018 iOS App Templates. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | let mainVC = UIViewController() 17 | mainVC.view.backgroundColor = .red 18 | 19 | let rootController = RootViewController(mainViewController: mainVC, topNavigationLeftImage: UIImage(named: "hamburger-menu-icon")) 20 | let menuVC = MenuViewController() 21 | menuVC.view.backgroundColor = .green 22 | 23 | let drawerVC = DrawerController(rootViewController: rootController, menuController: menuVC) 24 | self.addChild(drawerVC) 25 | view.addSubview(drawerVC.view) 26 | drawerVC.didMove(toParent: self) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 iOS App Templates 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Drawer menu implementation in Swift 5 2 | 3 | This is a very simple implementation of a slide menu in Swift 5. All you need is the three classes from DrawerMenu folder. Check out the Xcode project from DrawerMenuExample, if you want to see how to get started. Specifically, look into ViewController.swift class, viewDidLoad method. 4 | 5 | 6 | 7 | 8 |
9 | 10 | Supported by iOS App Templates. 11 | --------------------------------------------------------------------------------