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 @@ -15,6 +15,6 @@
+(AFPopupView *)popupWithView:(UIView *)popupView;

-(void)show;
-(void)hide;
-(void)hideWithActions:(void (^)(void))actions;

@end
7 changes: 5 additions & 2 deletions AFPopupView.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ -(void)show {

}

-(void)hide {
-(void)hideWithActions:(void (^)(void))actions {

[UIView animateWithDuration:0.4
delay:0
Expand Down Expand Up @@ -160,13 +160,16 @@ -(void)hide {
_renderImage.layer.transform = CATransform3DMakePerspective(0, 0);
} completion:^(BOOL finished) {
[self removeFromSuperview];
if (finished && actions) {
actions();
}
}];
}];
}

-(void)hideByTap {
if (_hideOnBackgroundTap) {
[self hide];
[self hideWithActions:nil];
}
}

Expand Down
Binary file modified Demo/.DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion Demo/AFPopup-Demo/AFPopupView.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

@interface AFPopupView : UIView

@property (nonatomic) BOOL hideOnBackgroundTap;

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

-(void)show;
-(void)hide;
-(void)hideWithActions:(void (^)(void))actions;

@end
14 changes: 13 additions & 1 deletion Demo/AFPopup-Demo/AFPopupView.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ +(AFPopupView *)popupWithView:(UIView *)popupView {
[view addSubview:view.backgroundShadowView];
[view addSubview:view.modalView];

UITapGestureRecognizer *hideGesture = [[UITapGestureRecognizer alloc] initWithTarget:view action:@selector(hideByTap)];
[view.backgroundShadowView addGestureRecognizer:hideGesture];

return view;
}

Expand Down Expand Up @@ -128,7 +131,7 @@ -(void)show {

}

-(void)hide {
-(void)hideWithActions:(void (^)(void))actions {

[UIView animateWithDuration:0.4
delay:0
Expand Down Expand Up @@ -157,10 +160,19 @@ -(void)hide {
_renderImage.layer.transform = CATransform3DMakePerspective(0, 0);
} completion:^(BOOL finished) {
[self removeFromSuperview];
if (finished && actions) {
actions();
}
}];
}];
}

-(void)hideByTap {
if (_hideOnBackgroundTap) {
[self hideWithActions:nil];
}
}

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

UIGraphicsBeginImageContextWithOptions(_renderImage.frame.size, view.opaque, [[UIScreen mainScreen] scale]);
Expand Down
2 changes: 1 addition & 1 deletion Demo/AFPopup-Demo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ -(void)go {

-(void)hide {

[_popup hide];
[_popup hideWithActions:nil];
}

-(void)didReceiveMemoryWarning {
Expand Down