-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished subclasing support, completed beta quality documentation, ne…
…ed to add subcloassing testing, unit testing
- Loading branch information
Showing
9 changed files
with
1,000 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// NDRevealView.h | ||
// NDRevealView | ||
// | ||
// Created by Nathan Day on 22/07/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface NDRevealView : UIView | ||
|
||
@property (nonatomic, getter=isExpanded) BOOL expanded; | ||
@property (retain) IBOutlet UIView * hideContent; | ||
|
||
- (IBAction)toggleExpansion:(id)sender; | ||
- (IBAction)expansion:(id)sender; | ||
- (IBAction)compact:(id)sender; | ||
|
||
- (void)setExpanded:(BOOL)expanded animate:(BOOL)animate; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// | ||
// NDRevealView.m | ||
// NDRevealView | ||
// | ||
// Created by Nathan Day on 22/07/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "NDRevealView.h" | ||
|
||
@interface NDRevealView () | ||
{ | ||
@private | ||
BOOL expanded; | ||
UIView * hideContent; | ||
} | ||
|
||
@end | ||
|
||
@implementation NDRevealView | ||
|
||
@synthesize expanded, | ||
hideContent; | ||
|
||
#pragma mark - | ||
#pragma mark Manually implemented properties | ||
|
||
- (void)setExpanded:(BOOL)anExpanded | ||
{ | ||
[self setExpanded:anExpanded animate:YES]; | ||
} | ||
|
||
- (void)setExpanded:(BOOL)anExpanded animate:(BOOL)anAnimate | ||
{ | ||
if( anExpanded != expanded ) | ||
{ | ||
CGRect theFrame = self.frame; | ||
if( anAnimate ) | ||
{ | ||
if( anExpanded ) | ||
{ | ||
theFrame.size.height += CGRectGetHeight(self.hideContent.frame); | ||
[UIView beginAnimations:@"animation2" context:NULL]; | ||
[UIView setAnimationDuration:0.3]; | ||
self.frame = theFrame; | ||
[UIView commitAnimations]; | ||
|
||
self.hideContent.hidden = NO; | ||
[UIView beginAnimations:@"animation1" context:NULL]; | ||
[UIView setAnimationDuration:0.3]; | ||
[UIView setAnimationDelay:0.3]; | ||
self.hideContent.alpha = 1.0; | ||
[UIView commitAnimations]; | ||
} | ||
else | ||
{ | ||
[UIView beginAnimations:@"animation1" context:NULL]; | ||
[UIView setAnimationDuration:0.3]; | ||
self.hideContent.alpha = 0.0; | ||
[UIView commitAnimations]; | ||
|
||
theFrame.size.height -= CGRectGetHeight(self.hideContent.frame); | ||
[UIView beginAnimations:@"animation2" context:NULL]; | ||
[UIView setAnimationDuration:0.3]; | ||
[UIView setAnimationDelegate:self]; | ||
[UIView setAnimationDidStopSelector:@selector(expandAnimationDidStop:finished:context:)]; | ||
[UIView setAnimationDelay:0.1]; | ||
self.frame = theFrame; | ||
[UIView commitAnimations]; | ||
} | ||
} | ||
else | ||
{ | ||
if( anExpanded ) | ||
{ | ||
theFrame.size.height += CGRectGetHeight(self.hideContent.frame); | ||
self.frame = theFrame; | ||
self.hideContent.hidden = NO; | ||
self.hideContent.alpha = 1.0; | ||
} | ||
else | ||
{ | ||
self.hideContent.alpha = 0.0; | ||
theFrame.size.height -= CGRectGetHeight(self.hideContent.frame); | ||
self.frame = theFrame; | ||
} | ||
|
||
} | ||
expanded = anExpanded; | ||
} | ||
} | ||
|
||
- (void)expandAnimationDidStop:(NSString *)anAnimationID finished:(NSNumber *)aFinished context:(void *)aContext | ||
{ | ||
self.hideContent.hidden = !self.isExpanded; | ||
} | ||
|
||
#pragma mark - View lifecycle | ||
|
||
- (void)awakeFromNib | ||
{ | ||
[super awakeFromNib]; | ||
[self setExpanded:NO animate:NO]; | ||
} | ||
|
||
#pragma mark - creation and destruction | ||
|
||
- (id)initWithFrame:(CGRect)aFrame | ||
{ | ||
if( (self = [super initWithFrame:aFrame]) != nil ) | ||
expanded = YES; | ||
return self; | ||
} | ||
|
||
- (id)initWithCoder:(NSCoder *)aDecoder | ||
{ | ||
if( (self = [super initWithCoder:aDecoder]) != nil ) | ||
expanded = YES; | ||
return self; | ||
} | ||
|
||
#pragma mark - Actions | ||
- (IBAction)toggleExpansion:(id)aSender { self.expanded = !self.isExpanded; } | ||
- (IBAction)expansion:(id)aSender { self.expanded = YES; } | ||
- (IBAction)compact:(id)aSender { self.expanded = NO; } | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.