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
2 changes: 1 addition & 1 deletion AFPopupView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

-(void)show;
-(void)hide;

-(void)hideAndRestore;
@end
24 changes: 23 additions & 1 deletion AFPopupView.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ @interface AFPopupView ()

@end

@implementation AFPopupView
@implementation AFPopupView{
BOOL _restoreable;
UIView * _popupView;
UIView * _originalSuperView;
NSUInteger _originalIndex;
}

+(AFPopupView *)popupWithView:(UIView *)popupView {

Expand All @@ -49,6 +54,10 @@ +(AFPopupView *)popupWithView:(UIView *)popupView {

AFPopupView *view = [[AFPopupView alloc] initWithFrame:rect];

view->_popupView = popupView;
view->_originalSuperView = [popupView superview];
view->_originalIndex = [[[popupView superview] subviews] indexOfObject:popupView];

view.modalView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height - (50 * 2))];
view.modalView.backgroundColor = [UIColor clearColor];
view.modalView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight |
Expand Down Expand Up @@ -170,6 +179,19 @@ -(void)hideByTap {
}
}

-(void)hideAndRestore {
_restoreable = YES;
[self hide];
}

- (void)removeFromSuperview; {
if(_restoreable && _originalSuperView && _popupView){
[_originalSuperView insertSubview:_popupView atIndex:_originalIndex];
_restoreable = NO;
}
[super removeFromSuperview];
}

-(UIImage *)imageWithView:(UIView *)view {

UIGraphicsBeginImageContextWithOptions(_renderImage.frame.size, view.opaque, [[UIScreen mainScreen] scale]);
Expand Down