MBProgressHUD Completed with image Swift

2k views Asked by At

After some tutorials and debug, I managed to have a MBProgressHUD (with cocoapods) working on my app (in Swift). Now, I'm trying to do a MBProgressHUD when the progress I want is completed. So now, I want to show a checkmark with some text. The problem is that I don't know how to put an image (icon) in front of the text.

My code working (without the checkmark):

self.spinningCompleted = MBProgressHUD.showHUDAddedTo(self.view, animated: true)
self.spinningCompleted.customView = ???????????????????????
self.spinningCompleted.mode = MBProgressHUDMode.CustomView
self.spinningCompleted.labelText = "Completed!"
self.spinningCompleted.userInteractionEnabled = false
self.spinningCompleted.hide(true, afterDelay: 2)

What I want but in objective-C:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
    HUD.mode = MBProgressHUDModeCustomView;
    [HUD hide:YES afterDelay:2];
}

Thanks in advance!

1

There are 1 answers

1
Himanshu gupta On BEST ANSWER

In Swift:

self.spinningCompleted.customView =  UIImageView(image: UIImage(named: "37x-Checkmark.png"))