Skip to content

Instantly share code, notes, and snippets.

@ngutman
Last active January 3, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngutman/8482226 to your computer and use it in GitHub Desktop.
Save ngutman/8482226 to your computer and use it in GitHub Desktop.
#import "GGDraggableView.h"
@interface GGDraggableView ()
@property (nonatomic, strong) UIPanGestureRecognizer *panGestureRecognizer;
@end
@implementation GGDraggableView
- (id)init
{
self = [super init];
if (!self) return nil;
self.backgroundColor = [UIColor greenColor];
self.panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dragged:)];
[self addGestureRecognizer:self.panGestureRecognizer];
[self loadImageAndStyle];
return self;
}
- (void)loadImageAndStyle
{
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bar"]];
[self addSubview:imageView];
self.layer.cornerRadius = 8;
self.layer.shadowOffset = CGSizeMake(7, 7);
self.layer.shadowRadius = 5;
self.layer.shadowOpacity = 0.5;
}
- (void)dragged:(UIGestureRecognizer *)gestureRecognizer
{
// TODO: Write Logic
}
- (void)dealloc
{
[self removeGestureRecognizer:self.panGestureRecognizer];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment