|
// |
|
// UIShadowButton.m |
|
// |
|
// Created by Javier Chavarri on 12/03/13. |
|
// |
|
|
|
#import "UIShadowButton.h" |
|
#import <QuartzCore/QuartzCore.h> |
|
#import <Foundation/Foundation.h> |
|
|
|
@implementation UIShadowButton |
|
|
|
-(void)setupView{ |
|
|
|
self.layer.backgroundColor = [UIColor blueColor].CGColor; |
|
self.layer.shadowColor = [UIColor blackColor].CGColor; |
|
self.layer.shadowOpacity = 0.65; |
|
self.layer.shadowRadius = 1.5f; |
|
self.layer.shadowOffset = CGSizeMake(1.5f, 1.5f); |
|
self.layer.borderColor = [UIColor blackColor].CGColor; |
|
self.layer.borderWidth = 1.0; |
|
|
|
} |
|
|
|
-(id)initWithFrame:(CGRect)frame{ |
|
if((self = [super initWithFrame:frame])){ |
|
[self setupView]; |
|
} |
|
|
|
return self; |
|
} |
|
|
|
-(id)initWithCoder:(NSCoder *)aDecoder{ |
|
if((self = [super initWithCoder:aDecoder])){ |
|
[self setupView]; |
|
} |
|
|
|
return self; |
|
} |
|
|
|
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ |
|
CGRect theFrame = self.frame; |
|
theFrame.origin.x += 2; |
|
theFrame.origin.y += 2; |
|
self.frame = theFrame; |
|
//self.contentEdgeInsets = UIEdgeInsetsMake(2.0,2.0,-2.0,-2.0); |
|
self.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); |
|
//self.layer.shadowOpacity = 0.8; |
|
|
|
[super touchesBegan:touches withEvent:event]; |
|
|
|
} |
|
|
|
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ |
|
CGRect theFrame = self.frame; |
|
theFrame.origin.x -= 2; |
|
theFrame.origin.y -= 2; |
|
self.frame = theFrame; |
|
//self.contentEdgeInsets = UIEdgeInsetsMake(0.0,0.0,0.0,0.0); |
|
self.layer.shadowOffset = CGSizeMake(1.5f, 1.5f); |
|
//self.layer.shadowOpacity = 0.5; |
|
|
|
[super touchesEnded:touches withEvent:event]; |
|
|
|
} |
|
|
|
@end |