Reputation: 8948
I want to add a custom cancel button to MBProgressHUD
, and I want it to be just right of text label. But MBProgresHUD
is drawn by overriding drawRect
method, so, while I can add button as subview to HUD, i don't know how large text label will be so I can position my button properly.
How can this be achieved?
Upvotes: 1
Views: 2462
Reputation: 14164
I'm not sure this is possible directly using MBProgressHUD
. Not without rewriting much of it.
One option could be to just add your own button as a subview of the view you are adding the HUD to that would just close the HUD or cancel the action.
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 50, 50, 50)]; // made up coords here
// set button stuff here
[self.view addSubview:button];
You will need to set the button actions, background or image (for look and feel), then add it to your view. Basically 2 views to achieve what you need. HUD and button. Probably a lot easier than rewriting MBProgressHUD
to allow buttons.
Upvotes: 1