Skip to content

Commit

Permalink
Updated with Swift 2.2 and an an Example View Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishkakkad8 committed Apr 8, 2016
1 parent 8f9002b commit ee872ba
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 60 deletions.
12 changes: 8 additions & 4 deletions AKSwiftSlideMenu.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

/* Begin PBXBuildFile section */
753A55C31BB073E900254F27 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A55C21BB073E900254F27 /* AppDelegate.swift */; };
753A55C51BB073E900254F27 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A55C41BB073E900254F27 /* ViewController.swift */; };
753A55C81BB073E900254F27 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 753A55C61BB073E900254F27 /* Main.storyboard */; };
753A55CA1BB073E900254F27 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 753A55C91BB073E900254F27 /* Images.xcassets */; };
753A55CD1BB073E900254F27 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 753A55CB1BB073E900254F27 /* LaunchScreen.xib */; };
753A55D91BB073E900254F27 /* AKSwiftSlideMenuTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A55D81BB073E900254F27 /* AKSwiftSlideMenuTests.swift */; };
753A55E31BB0753B00254F27 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A55E21BB0753B00254F27 /* MenuViewController.swift */; };
753A55E51BB0755100254F27 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753A55E41BB0755100254F27 /* BaseViewController.swift */; };
C6EEF9F61CB7E2AD00A3DC6D /* PlayVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6EEF9F51CB7E2AD00A3DC6D /* PlayVC.swift */; };
C6EEF9F81CB7E4E000A3DC6D /* HomeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6EEF9F71CB7E4E000A3DC6D /* HomeVC.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -31,7 +32,6 @@
753A55BD1BB073E900254F27 /* AKSwiftSlideMenu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AKSwiftSlideMenu.app; sourceTree = BUILT_PRODUCTS_DIR; };
753A55C11BB073E900254F27 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
753A55C21BB073E900254F27 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
753A55C41BB073E900254F27 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
753A55C71BB073E900254F27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
753A55C91BB073E900254F27 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
753A55CC1BB073E900254F27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
Expand All @@ -40,6 +40,8 @@
753A55D81BB073E900254F27 /* AKSwiftSlideMenuTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AKSwiftSlideMenuTests.swift; sourceTree = "<group>"; };
753A55E21BB0753B00254F27 /* MenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
753A55E41BB0755100254F27 /* BaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = "<group>"; };
C6EEF9F51CB7E2AD00A3DC6D /* PlayVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayVC.swift; sourceTree = "<group>"; };
C6EEF9F71CB7E4E000A3DC6D /* HomeVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeVC.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -82,9 +84,10 @@
isa = PBXGroup;
children = (
753A55C21BB073E900254F27 /* AppDelegate.swift */,
753A55C41BB073E900254F27 /* ViewController.swift */,
C6EEF9F71CB7E4E000A3DC6D /* HomeVC.swift */,
753A55E41BB0755100254F27 /* BaseViewController.swift */,
753A55E21BB0753B00254F27 /* MenuViewController.swift */,
C6EEF9F51CB7E2AD00A3DC6D /* PlayVC.swift */,
753A55C61BB073E900254F27 /* Main.storyboard */,
753A55C91BB073E900254F27 /* Images.xcassets */,
753A55CB1BB073E900254F27 /* LaunchScreen.xib */,
Expand Down Expand Up @@ -220,8 +223,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
753A55C51BB073E900254F27 /* ViewController.swift in Sources */,
753A55E51BB0755100254F27 /* BaseViewController.swift in Sources */,
C6EEF9F61CB7E2AD00A3DC6D /* PlayVC.swift in Sources */,
C6EEF9F81CB7E4E000A3DC6D /* HomeVC.swift in Sources */,
753A55E31BB0753B00254F27 /* MenuViewController.swift in Sources */,
753A55C31BB073E900254F27 /* AppDelegate.swift in Sources */,
);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "753A55BC1BB073E900254F27"
BuildableName = "AKSwiftSlideMenu.app"
BlueprintName = "AKSwiftSlideMenu"
ReferencedContainer = "container:AKSwiftSlideMenu.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "753A55D11BB073E900254F27"
BuildableName = "AKSwiftSlideMenuTests.xctest"
BlueprintName = "AKSwiftSlideMenuTests"
ReferencedContainer = "container:AKSwiftSlideMenu.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "753A55BC1BB073E900254F27"
BuildableName = "AKSwiftSlideMenu.app"
BlueprintName = "AKSwiftSlideMenu"
ReferencedContainer = "container:AKSwiftSlideMenu.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "753A55BC1BB073E900254F27"
BuildableName = "AKSwiftSlideMenu.app"
BlueprintName = "AKSwiftSlideMenu"
ReferencedContainer = "container:AKSwiftSlideMenu.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "753A55BC1BB073E900254F27"
BuildableName = "AKSwiftSlideMenu.app"
BlueprintName = "AKSwiftSlideMenu"
ReferencedContainer = "container:AKSwiftSlideMenu.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AKSwiftSlideMenu.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>753A55BC1BB073E900254F27</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>753A55D11BB073E900254F27</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
24 changes: 21 additions & 3 deletions AKSwiftSlideMenu/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="DGj-7d-jfR">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="DGj-7d-jfR">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--AK Swift Slider Menu-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="AKSwiftSlideMenu" customModuleProvider="target" sceneMemberID="viewController">
<viewController restorationIdentifier="Home" storyboardIdentifier="Home" id="vXZ-lx-hvc" customClass="HomeVC" customModule="AKSwiftSlideMenu" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</view>
<navigationItem key="navigationItem" title="AK Swift Slider Menu" id="a1u-Ki-tSz"/>
<connections>
<segue destination="khG-SL-0rk" kind="push" identifier="pushToPlay" id="WvG-AQ-ekI"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="694" y="340"/>
</scene>
<!--Play-->
<scene sceneID="q6l-iR-WN3">
<objects>
<viewController restorationIdentifier="PlayVC" storyboardIdentifier="PlayVC" id="khG-SL-0rk" customClass="PlayVC" customModule="AKSwiftSlideMenu" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8Tm-V4-HTY">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" title="Play" id="f24-Ia-thn"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="mmn-PL-HS6" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1111" y="340"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="nrt-yR-DmY">
<objects>
Expand Down
57 changes: 33 additions & 24 deletions AKSwiftSlideMenu/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,61 @@ class BaseViewController: UIViewController, SlideMenuDelegate {
switch(index){
case 0:
print("Home\n", terminator: "")

self.openViewControllerBasedOnIdentifier("Home")

break
case 1:
print("Play\n", terminator: "")
break
case 2:
print("Camera\n", terminator: "")

self.openViewControllerBasedOnIdentifier("PlayVC")

break
default:
print("default\n", terminator: "")
}
}

func openViewControllerBasedOnIdentifier(strIdentifier:String){
let destViewController : UIViewController = self.storyboard!.instantiateViewControllerWithIdentifier(strIdentifier)

let topViewController : UIViewController = self.navigationController!.topViewController!

if (topViewController.restorationIdentifier! == destViewController.restorationIdentifier!){
print("Same VC")
} else {
self.navigationController!.pushViewController(destViewController, animated: true)
}
}

func addSlideMenuButton(){
let btnShowMenu = UIButton(type: UIButtonType.System)
btnShowMenu.setImage(self.defaultMenuImage(), forState: UIControlState.Normal)
btnShowMenu.frame = CGRectMake(0, 0, 30, 30)
btnShowMenu.addTarget(self, action: "onSlideMenuButtonPressed:", forControlEvents: UIControlEvents.TouchUpInside)
btnShowMenu.addTarget(self, action: #selector(BaseViewController.onSlideMenuButtonPressed(_:)), forControlEvents: UIControlEvents.TouchUpInside)
let customBarItem = UIBarButtonItem(customView: btnShowMenu)
self.navigationItem.leftBarButtonItem = customBarItem;
}

func defaultMenuImage() -> UIImage {
var defaultMenuImage = UIImage()

struct Static {
static var onceToken: dispatch_once_t = 0
}
UIGraphicsBeginImageContextWithOptions(CGSizeMake(30, 22), false, 0.0)

dispatch_once(&Static.onceToken, { () -> Void in
UIGraphicsBeginImageContextWithOptions(CGSizeMake(30, 22), false, 0.0)

UIColor.blackColor().setFill()
UIBezierPath(rect: CGRectMake(0, 3, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 10, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 17, 30, 1)).fill()

UIColor.whiteColor().setFill()
UIBezierPath(rect: CGRectMake(0, 4, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 11, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 18, 30, 1)).fill()

defaultMenuImage = UIGraphicsGetImageFromCurrentImageContext()

UIGraphicsEndImageContext()
})
UIColor.blackColor().setFill()
UIBezierPath(rect: CGRectMake(0, 3, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 10, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 17, 30, 1)).fill()

UIColor.whiteColor().setFill()
UIBezierPath(rect: CGRectMake(0, 4, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 11, 30, 1)).fill()
UIBezierPath(rect: CGRectMake(0, 18, 30, 1)).fill()

defaultMenuImage = UIGraphicsGetImageFromCurrentImageContext()

UIGraphicsEndImageContext()

return defaultMenuImage;
}

Expand Down
35 changes: 35 additions & 0 deletions AKSwiftSlideMenu/HomeVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// HomeVC.swift
// AKSwiftSlideMenu
//
// Created by MAC-186 on 4/8/16.
// Copyright © 2016 Kode. All rights reserved.
//

import UIKit

class HomeVC: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
addSlideMenuButton()
// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/

}
1 change: 0 additions & 1 deletion AKSwiftSlideMenu/MenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class MenuViewController: UIViewController, UITableViewDataSource, UITableViewDe
func updateArrayMenuOptions(){
arrayMenuOptions.append(["title":"Home", "icon":"HomeIcon"])
arrayMenuOptions.append(["title":"Play", "icon":"PlayIcon"])
arrayMenuOptions.append(["title":"Camera", "icon":"CameraIcon"])

tblMenuOptions.reloadData()
}
Expand Down
Loading

0 comments on commit ee872ba

Please sign in to comment.