Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UIPangestureRecognizer to open and close Menu #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions TWTSideMenuViewController-Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
A495C4D717BC109600B880E4 /* TWTMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A495C4D617BC109600B880E4 /* TWTMenuViewController.m */; };
A495C4DA17BC109F00B880E4 /* TWTMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A495C4D917BC109F00B880E4 /* TWTMainViewController.m */; };
A495C4DC17BC11F500B880E4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A495C4DB17BC11F500B880E4 /* Images.xcassets */; };
ABED77A018006D5300D92D6F /* UIView-Transform.m in Sources */ = {isa = PBXBuildFile; fileRef = ABED779F18006D5300D92D6F /* UIView-Transform.m */; };
ABED77A118006D5300D92D6F /* UIView-Transform.m in Sources */ = {isa = PBXBuildFile; fileRef = ABED779F18006D5300D92D6F /* UIView-Transform.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -59,6 +61,8 @@
A495C4D817BC109F00B880E4 /* TWTMainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWTMainViewController.h; sourceTree = "<group>"; };
A495C4D917BC109F00B880E4 /* TWTMainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWTMainViewController.m; sourceTree = "<group>"; };
A495C4DB17BC11F500B880E4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
ABED779E18006D5300D92D6F /* UIView-Transform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView-Transform.h"; sourceTree = "<group>"; };
ABED779F18006D5300D92D6F /* UIView-Transform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView-Transform.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -121,6 +125,8 @@
children = (
A43DC61B17CCE1A500F16C6A /* galaxy.png */,
A495C4DB17BC11F500B880E4 /* Images.xcassets */,
ABED779E18006D5300D92D6F /* UIView-Transform.h */,
ABED779F18006D5300D92D6F /* UIView-Transform.m */,
A4485E7217BBCA75002B32C4 /* TWTAppDelegate.h */,
A4485E7317BBCA75002B32C4 /* TWTAppDelegate.m */,
A495C4D517BC109600B880E4 /* TWTMenuViewController.h */,
Expand Down Expand Up @@ -272,6 +278,7 @@
A4485E7017BBCA75002B32C4 /* main.m in Sources */,
A45D359417BBDF6B00BEF872 /* TWTSideMenuViewController.m in Sources */,
A495C4D717BC109600B880E4 /* TWTMenuViewController.m in Sources */,
ABED77A018006D5300D92D6F /* UIView-Transform.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -280,6 +287,7 @@
buildActionMask = 2147483647;
files = (
A4485E8917BBCA75002B32C4 /* TWTSideMenuViewController_SampleTests.m in Sources */,
ABED77A118006D5300D92D6F /* UIView-Transform.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -388,6 +396,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: xianhua zeng (URASQ4RCLH)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TWTSideMenuViewController-Sample/TWTSideMenuViewController-Sample-Prefix.pch";
INFOPLIST_FILE = "TWTSideMenuViewController-Sample/TWTSideMenuViewController-Sample-Info.plist";
Expand Down
26 changes: 17 additions & 9 deletions TWTSideMenuViewController-Sample/TWTAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,28 @@ @interface TWTAppDelegate ()

@implementation TWTAppDelegate

- (TWTMenuViewController *)menuViewController {
if (!_menuViewController) {
_menuViewController = [[TWTMenuViewController alloc] init];
}
return _menuViewController;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.menuViewController = [[TWTMenuViewController alloc] initWithNibName:nil bundle:nil];
self.mainViewController = [[TWTMainViewController alloc] initWithNibName:nil bundle:nil];
self.window.backgroundColor = [UIColor whiteColor];


self.mainViewController = [[TWTMainViewController alloc] init];

_sideMenuViewController = [[TWTSideMenuViewController alloc] initWithMenuViewController:self.menuViewController mainViewController:[[UINavigationController alloc] initWithRootViewController:self.mainViewController]];
_sideMenuViewController.shadowColor = [UIColor blackColor];
_sideMenuViewController.edgeOffset = (UIOffset) { .horizontal = 18.0f };
_sideMenuViewController.zoomScale = 0.65f;
self.window.rootViewController = _sideMenuViewController;

self.sideMenuViewController = [[TWTSideMenuViewController alloc] initWithMenuViewController:self.menuViewController mainViewController:[[UINavigationController alloc] initWithRootViewController:self.mainViewController]];
self.sideMenuViewController.shadowColor = [UIColor blackColor];
self.sideMenuViewController.edgeOffset = (UIOffset) { .horizontal = 18.0f };
self.sideMenuViewController.zoomScale = 0.5634f;
self.window.rootViewController = self.sideMenuViewController;

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
Expand Down
18 changes: 18 additions & 0 deletions TWTSideMenuViewController-Sample/TWTMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ @interface TWTMainViewController ()

@implementation TWTMainViewController

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"main viewDidAppear");
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"main viewWillAppear");
}

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"main viewDidDisappear");
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"main viewWillDisappear");
}

- (void)viewDidLoad
{
[super viewDidLoad];
Expand Down
21 changes: 20 additions & 1 deletion TWTSideMenuViewController-Sample/TWTMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ @interface TWTMenuViewController ()

@implementation TWTMenuViewController

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"left viewDidAppear");
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"left viewWillAppear");
}

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"left viewDidDisappear");
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"left viewWillDisappear");
}

- (void)viewDidLoad
{
[super viewDidLoad];
Expand All @@ -27,7 +45,8 @@ - (void)viewDidLoad
self.backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"galaxy"]];

CGRect imageViewRect = [[UIScreen mainScreen] bounds];
imageViewRect.size.width += 589;
imageViewRect.size.width += 909;
imageViewRect.origin.x -= 320;
self.backgroundImageView.frame = imageViewRect;
self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:self.backgroundImageView];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.twotoasters.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.SJQ-IT.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
29 changes: 29 additions & 0 deletions TWTSideMenuViewController-Sample/UIView-Transform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface UIView (Transform)
@property (nonatomic) CGFloat rotation;
@property (nonatomic) CGFloat xscale;
@property (nonatomic) CGFloat yscale;
@property (nonatomic) CGFloat tx;
@property (nonatomic) CGFloat ty;

@property (nonatomic, readonly) CGRect originalFrame;
@property (nonatomic, readonly) CGPoint originalCenter;

@property (nonatomic, readonly) CGPoint transformedTopLeft;
@property (nonatomic, readonly) CGPoint transformedTopRight;
@property (nonatomic, readonly) CGPoint transformedBottomLeft;
@property (nonatomic, readonly) CGPoint transformedBottomRight;

@property (nonatomic, readonly) NSString *transformDescription;

- (CGPoint) pointInTransformedView: (CGPoint) pointInParentCoordinates;
- (BOOL) intersectsView: (UIView *) aView;
@end
Loading