Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/UIViewController+KNSemiModal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define kSemiModalDidShowNotification @"kSemiModalDidShowNotification"
#define kSemiModalDidHideNotification @"kSemiModalDidHideNotification"
#define kSemiModalWasResizedNotification @"kSemiModalWasResizedNotification"
#define kSemiModalWasMovedNotification @"kSemiModalWasMovedNotification"


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

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

Expand Down
18 changes: 18 additions & 0 deletions Source/UIViewController+KNSemiModal.m
Original file line number Diff line number Diff line change
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


Expand Down