Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to move the modal view up #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/UIViewController+KNSemiModal.h
Expand Up @@ -32,6 +32,8 @@
#define kSemiModalDidShowNotification @"kSemiModalDidShowNotification" #define kSemiModalDidShowNotification @"kSemiModalDidShowNotification"
#define kSemiModalDidHideNotification @"kSemiModalDidHideNotification" #define kSemiModalDidHideNotification @"kSemiModalDidHideNotification"
#define kSemiModalWasResizedNotification @"kSemiModalWasResizedNotification" #define kSemiModalWasResizedNotification @"kSemiModalWasResizedNotification"
#define kSemiModalWasMovedNotification @"kSemiModalWasMovedNotification"



extern const struct KNSemiModalOptionKeys { extern const struct KNSemiModalOptionKeys {
__unsafe_unretained NSString *traverseParentHierarchy; // boxed BOOL. default is YES. __unsafe_unretained NSString *traverseParentHierarchy; // boxed BOOL. default is YES.
Expand Down Expand Up @@ -78,6 +80,7 @@ typedef void (^KNTransitionCompletionBlock)(void);


// Dismiss & resize // Dismiss & resize
-(void)resizeSemiView:(CGSize)newSize; -(void)resizeSemiView:(CGSize)newSize;
-(void)moveSemiViewToTopWithMargin:(CGFloat)topMargin;
-(void)dismissSemiModalView; -(void)dismissSemiModalView;
-(void)dismissSemiModalViewWithCompletion:(KNTransitionCompletionBlock)completion; -(void)dismissSemiModalViewWithCompletion:(KNTransitionCompletionBlock)completion;


Expand Down
18 changes: 18 additions & 0 deletions Source/UIViewController+KNSemiModal.m
Expand Up @@ -363,6 +363,24 @@ - (void)resizeSemiView:(CGSize)newSize {
}]; }];
} }


-(void)moveSemiViewToTopWithMargin:(CGFloat)topMargin {
UIView * target = [self parentTarget];
UIView * modal = [target.subviews objectAtIndex:target.subviews.count-1];
CGRect newFrame = modal.frame;
newFrame.origin.y = topMargin;
NSTimeInterval duration = [[self ym_optionOrDefaultForKey:KNSemiModalOptionKeys.animationDuration] doubleValue];
[UIView animateWithDuration:duration animations:^{
modal.frame = newFrame;
} completion:^(BOOL finished) {
if(finished){
[[NSNotificationCenter defaultCenter] postNotificationName:kSemiModalWasMovedNotification
object:self];
}
}];

}


@end @end




Expand Down