Swift 4 SVProgressHUD未显示加载

时间:2018-04-18 00:24:01

标签: swift xcode swift4

我已经安装了cooapods和SVProgressHub。我无法弄清楚如何显示SVProgressHUB加载屏幕。

SVProgressHUD.show()

这是我的视图控制器。 我是swift和堆栈溢出的新手。干杯!

2 个答案:

答案 0 :(得分:0)

不清楚你在问什么,你想在启动画面中调用SVProgressHUD吗?或第一个视图控制器打开时。

如果您在拨打.show和拨打.dismiss之间没有处理任何内容,即使您正在拨打电话,也可能看不到它。

在AppDelegate didFinishLaunchingWithOptions中你可以放置一些默认值

    SVProgressHUD.setBorderColor(kBrandBlue)
    SVProgressHUD.setBorderWidth(1.0)
    SVProgressHUD.setCornerRadius(44.0)
    SVProgressHUD.setForegroundColor(.blue)
    SVProgressHUD.setRingThickness(4.0)
    SVProgressHUD.setGraceTimeInterval(0.5)

我不确定默认的宽限期是什么,但你可能想检查一下。

如果你调用.show并且不调用.dismiss,那么它将永远保持旋转,所以只需将.show放在viewDtroller的viewDidLoad中,看看它是否出现。

希望有所帮助

答案 1 :(得分:0)

你可以小心地试试这个:

SVProgressHUD.setDefaultStyle(.custom)
SVProgressHUD.setDefaultMaskType(.custom)
SVProgressHUD.setForegroundColor(UIColor.red)           //Ring Color
SVProgressHUD.setBackgroundColor(UIColor.yellow)        //HUD Color
SVProgressHUD.setBackgroundLayerColor(UIColor.green)    //Background Color
SVProgressHUD.show()

输出:

enter image description here

干杯!