Skip to content

Commit

Permalink
Adding shade color to alert view controller to allow adjustments in s…
Browse files Browse the repository at this point in the history
…ubclasses.
  • Loading branch information
devinross committed Jun 16, 2014
1 parent fa7f2a4 commit 1819bbc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/TapkuLibrary/TKAlertViewController.h
Expand Up @@ -44,6 +44,9 @@
/** The main view to display content on. */
@property (nonatomic,strong) UIView *alertView;

@property (nonatomic,strong) UIColor *backgroundShadeColor;


///----------------------------
/// @name Displaying and hiding alert
///----------------------------
Expand Down
26 changes: 16 additions & 10 deletions src/TapkuLibrary/TKAlertViewController.m
Expand Up @@ -57,6 +57,8 @@ - (NSUInteger) supportedInterfaceOrientations{
- (void) loadView{
[super loadView];

self.backgroundShadeColor = [UIColor colorWithWhite:0 alpha:0.1];

CGSize s = CGSizeMake(280, 300);
CGRect alertRect = CGRectMakeWithSize( (CGRectGetWidth(self.view.frame)- s.width)/2.0f, (CGRectGetHeight(self.view.frame)- s.height)/2.0f, s);

Expand All @@ -68,7 +70,7 @@ - (void) loadView{
self.alertView.layer.shadowOpacity = 0.1;
self.alertView.layer.cornerRadius = 8;
[self.view addSubview:self.alertView];

self.alertView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

}
Expand Down Expand Up @@ -120,17 +122,15 @@ - (void) showAlertView:(id<UIViewControllerContextTransitioning>)transitionConte
UIView *containerView = [transitionContext containerView];
[containerView addSubview:toVC.view];



toVC.view.frame = CGRectMake(0, 0, CGRectGetWidth(containerView.frame), CGRectGetHeight(containerView.frame));
toVC.view.alpha = 0;
toVC.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
self.alertView.alpha = 0;


self.alertView.transform = CGScale(0.8, 0.8);

[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toVC.view.alpha = 1;
toVC.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1];
toVC.view.layer.backgroundColor = self.backgroundShadeColor.CGColor;
self.alertView.alpha = 1;
}];


Expand Down Expand Up @@ -179,10 +179,16 @@ - (void) hideAlertView:(id<UIViewControllerContextTransitioning>)transitionConte
[self.animator addBehavior:behav];


[UIView animateWithDuration:0.4 delay:0 options:0 animations:^{
self.view.layer.backgroundColor = [UIColor colorWithWhite:0 alpha:0.0].CGColor;

}completion:nil];



[UIView animateWithDuration:0.4 delay:0.5f options:0 animations:^{
self.view.alpha = 0;
self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.0];

self.alertView.alpha = 0.8;

}completion:^(BOOL finished){
[transitionContext completeTransition:YES];
}];
Expand Down

0 comments on commit 1819bbc

Please sign in to comment.