Skip to content

Instantly share code, notes, and snippets.

View ngutman's full-sized avatar

Nimrod Gutman ngutman

View GitHub Profile
- (void)dragged:(UIPanGestureRecognizer *)gestureRecognizer
{
CGFloat xDistance = [gestureRecognizer translationInView:self].x;
CGFloat yDistance = [gestureRecognizer translationInView:self].y;
switch (gestureRecognizer.state) {
case UIGestureRecognizerStateBegan:{
self.originalPoint = self.center;
break;
};
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (!self) return nil;
self.panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dragged:)];
[self addGestureRecognizer:self.panGestureRecognizer];
[self loadImageAndStyle];
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger , GGOverlayViewMode) {
GGOverlayViewModeLeft,
GGOverlayViewModeRight
};
@interface GGOverlayView : UIView
@property (nonatomic) GGOverlayViewMode mode;
@end
#import "GGOverlayView.h"
@interface GGOverlayView ()
@property (nonatomic, strong) UIImageView *imageView;
@end
@implementation GGOverlayView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
- (void)dragged:(UIPanGestureRecognizer *)gestureRecognizer
{
CGFloat xDistance = [gestureRecognizer translationInView:self].x;
CGFloat yDistance = [gestureRecognizer translationInView:self].y;
switch (gestureRecognizer.state) {
case UIGestureRecognizerStateBegan:{
self.originalPoint = self.center;
break;
};
#import "GGDraggableView.h"
@interface GGDraggableView ()
@property (nonatomic, strong) UIPanGestureRecognizer *panGestureRecognizer;
@end
@implementation GGDraggableView
- (id)init
{
#import "GGView.h"
#import "GGDraggableView.h"
@interface GGView ()
@property (nonatomic, strong) GGDraggableView *draggableView;
@end
@implementation GGView
- (id)init
@ngutman
ngutman / gist:7609370
Created November 23, 2013 00:52
Add a direction to the animation
- (void)loadViewController:(UIViewController *)vc
fromLeft:(BOOL)fromLeft
{
[self addChildViewController:vc];
if (!self.currentVC) {
[self.view addSubview:vc.view];
vc.view.frame = self.view.bounds;
self.currentVC = vc;
return;
}
@ngutman
ngutman / gist:7609367
Created November 23, 2013 00:51
connect it to the tabTapped
- (void)tabTapped
{
if ([self.currentVC isKindOfClass:[GGViewController1 class]]) {
[self loadViewController:[[GGViewController2 alloc] init]];
} else {
[self loadViewController:[[GGViewController1 alloc] init]];
}
}
@ngutman
ngutman / gist:7609358
Created November 23, 2013 00:50
GGViewController1
#import "GGViewController1.h"
@interface GGViewController1 ()
@end
@implementation GGViewController1
- (void)viewDidLoad
{