Skip to content

Commit

Permalink
Uploading project.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeahmarani committed Apr 6, 2011
1 parent e726d42 commit 6a2dce1
Show file tree
Hide file tree
Showing 4 changed files with 653 additions and 539 deletions.
1 change: 0 additions & 1 deletion MAConfirmButton/MAConfirmButton.h
Expand Up @@ -31,6 +31,5 @@
- (void)disableWithTitle:(NSString *)t;
- (void)setAnchor:(CGPoint)a;
- (void)setTintColor:(UIColor *)color;
- (void)toggle;

@end
128 changes: 68 additions & 60 deletions MAConfirmButton/MAConfirmButton.m
Expand Up @@ -12,6 +12,14 @@
#define kPadding 20.0
#define kFontSize 14.0

@interface MAConfirmButton ()
- (void)toggle;
- (void)setupLayers;
- (void)cancel;
- (void)lighten;
- (void)darken;
@end

@implementation MAConfirmButton

@synthesize title, confirm, disabled, tint;
Expand All @@ -34,18 +42,60 @@ + (MAConfirmButton *)buttonWithDisabledTitle:(NSString *)t{
return button;
}

-(void)setSelected:(BOOL)s{
if(cancelOverlay){
[cancelOverlay removeFromSuperview];
cancelOverlay = nil;
- (id)initWithDisabledTitle:(NSString *)t{
self = [super initWithFrame:CGRectMake(300, 150, 75, 26)];
if(self != nil){
disabled = [t retain];

self.layer.needsDisplayOnBoundsChange = YES;

CGSize size = [disabled sizeWithFont:[UIFont boldSystemFontOfSize:kFontSize]];
CGRect r = self.frame;
r.size.width = size.width+kPadding;
self.frame = r;

[self setTitle:disabled forState:UIControlStateNormal];
[self setTitleColor:[UIColor colorWithWhite:0.6 alpha:1] forState:UIControlStateNormal];
[self setTitleShadowColor:[UIColor colorWithWhite:1 alpha:1] forState:UIControlStateNormal];

self.titleLabel.textAlignment = UITextAlignmentCenter;
self.titleLabel.shadowOffset = CGSizeMake(0, 1);
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.font = [UIFont boldSystemFontOfSize:kFontSize];
self.tint = [UIColor colorWithWhite:0.85 alpha:1];

[self setupLayers];
}
selected = s;
[self toggle];
return self;
}

- (void)disableWithTitle:(NSString *)t{
self.disabled = [t retain];
[self toggle];
- (id)initWithTitle:(NSString *)t confirm:(NSString *)c{
self = [super initWithFrame:CGRectMake(300, 150, 75, 26)];
if(self != nil){

self.title = [t retain];
self.confirm = [c retain];

self.layer.needsDisplayOnBoundsChange = YES;

CGSize size = [title sizeWithFont:[UIFont boldSystemFontOfSize:kFontSize]];
CGRect r = self.frame;
r.size.width = size.width+kPadding;
self.frame = r;

[self setTitle:title forState:UIControlStateNormal];
[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self setTitleShadowColor:[UIColor colorWithWhite:0 alpha:0.5] forState:UIControlStateNormal];

self.titleLabel.textAlignment = UITextAlignmentCenter;
self.titleLabel.shadowOffset = CGSizeMake(0, -1);
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.font = [UIFont boldSystemFontOfSize:kFontSize];
self.tint = [UIColor colorWithRed:0.220 green:0.357 blue:0.608 alpha:1];

[self setupLayers];
}
return self;
}

-(void)toggle{
Expand Down Expand Up @@ -152,60 +202,18 @@ - (void)setupLayers{

}

- (id)initWithDisabledTitle:(NSString *)t{
self = [super initWithFrame:CGRectMake(300, 150, 75, 26)];
if(self != nil){
disabled = [t retain];

self.layer.needsDisplayOnBoundsChange = YES;

CGSize size = [disabled sizeWithFont:[UIFont boldSystemFontOfSize:kFontSize]];
CGRect r = self.frame;
r.size.width = size.width+kPadding;
self.frame = r;

[self setTitle:disabled forState:UIControlStateNormal];
[self setTitleColor:[UIColor colorWithWhite:0.6 alpha:1] forState:UIControlStateNormal];
[self setTitleShadowColor:[UIColor colorWithWhite:1 alpha:1] forState:UIControlStateNormal];

self.titleLabel.textAlignment = UITextAlignmentCenter;
self.titleLabel.shadowOffset = CGSizeMake(0, 1);
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.font = [UIFont boldSystemFontOfSize:kFontSize];
self.tint = [UIColor colorWithWhite:0.85 alpha:1];

[self setupLayers];
-(void)setSelected:(BOOL)s{
if(cancelOverlay){
[cancelOverlay removeFromSuperview];
cancelOverlay = nil;
}
return self;
selected = s;
[self toggle];
}

- (id)initWithTitle:(NSString *)t confirm:(NSString *)c{
self = [super initWithFrame:CGRectMake(300, 150, 75, 26)];
if(self != nil){

self.title = [t retain];
self.confirm = [c retain];

self.layer.needsDisplayOnBoundsChange = YES;

CGSize size = [title sizeWithFont:[UIFont boldSystemFontOfSize:kFontSize]];
CGRect r = self.frame;
r.size.width = size.width+kPadding;
self.frame = r;

[self setTitle:title forState:UIControlStateNormal];
[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self setTitleShadowColor:[UIColor colorWithWhite:0 alpha:0.5] forState:UIControlStateNormal];

self.titleLabel.textAlignment = UITextAlignmentCenter;
self.titleLabel.shadowOffset = CGSizeMake(0, -1);
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.font = [UIFont boldSystemFontOfSize:kFontSize];
self.tint = [UIColor colorWithRed:0.220 green:0.357 blue:0.608 alpha:1];

[self setupLayers];
}
return self;
- (void)disableWithTitle:(NSString *)t{
self.disabled = [t retain];
[self toggle];
}

-(void)setAnchor:(CGPoint)anchor{
Expand Down
2 changes: 1 addition & 1 deletion README.textile
Expand Up @@ -4,7 +4,7 @@ MAConfirmButton is an animated subclass of UIButton that replicates and improves

h2. Usage

I attempted to make this class as "drop-in" as possible with regards to it being a subclass of UIButton.
I attempted to make this class as "drop-in" as possible since it is, after all, a subclass of UIButton.

h3. Init

Expand Down

0 comments on commit 6a2dce1

Please sign in to comment.