MBProgressHUD已完成图像Swift

时间:2015-06-07 14:11:38

标签: objective-c xcode swift mbprogresshud

在一些教程和调试之后,我设法在我的应用程序(在Swift中)上运行MBProgressHUD(使用cocoapods)。现在,当我想要的进度完成时,我正试图做一个MBProgressHUD。所以现在,我想显示带有一些文字的复选标记。问题是我不知道如何在图片前放置图像(图标)。

我的代码正常工作(没有复选标记):

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)

我想要的但是在目标-C:

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

提前致谢!

1 个答案:

答案 0 :(得分:4)

在斯威夫特:

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