Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
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
6 changes: 6 additions & 0 deletions MBProgressHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) {
};

typedef void (^MBProgressHUDCompletionBlock)(void);
typedef void (^MBProgressHUDTappedBlock)(void);


NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -183,6 +184,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (copy, nullable) MBProgressHUDCompletionBlock completionBlock;

/**
* Called after tapping the HUD or backgroundView
*/
@property (copy, nullable) MBProgressHUDTappedBlock tappedBlock;

/**
* Grace period is the time (in seconds) that the invoked method may be run without
* showing the HUD. If the task finishes before the grace time runs out, the HUD will
Expand Down
16 changes: 16 additions & 0 deletions MBProgressHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ - (void)commonInit {
[self setupViews];
[self updateIndicators];
[self registerForNotifications];
[self setupGestureRecognizer];
}

- (instancetype)initWithFrame:(CGRect)frame {
Expand Down Expand Up @@ -506,6 +507,12 @@ - (void)updateBezelMotionEffects {
}
}

- (void)setupGestureRecognizer {
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_hudTapped:)];
[self.backgroundView addGestureRecognizer:recognizer];
[self addGestureRecognizer:recognizer];
}

#pragma mark - Layout

- (void)updateConstraints {
Expand Down Expand Up @@ -805,6 +812,15 @@ - (void)updateForCurrentOrientationAnimated:(BOOL)animated {
#endif
}

#pragma mark - Private

- (void)_hudTapped:(UIGestureRecognizer *)recognizer
{
if (self.tappedBlock != nil) {
self.tappedBlock();
}
}

@end


Expand Down