MBProgressHUD 水平进度条xamarin ios.



>我需要在水平进度条中显示加载状态。 我正在 xamarin ios 中使用软件包 MBProgressHUD

我有这个方法,

public void ShowProgressBar(string title, string message, int max, int 
progress)
{
UIViewController controller = 
UIApplication.SharedApplication.KeyWindow.RootViewController;
hud = new MTMBProgressHUD(controller.View);
controller.View.AddSubview(hud);
hud.Color = UIColor.Clear.FromHex(0x8BC34A);
hud.Mode = MBProgressHUDMode.DeterminateHorizontalBar;
hud.Progress = progress;
}

最大值为 18,进度参数从 1 开始,此方法调用 18 次。 当此方法首次调用 'd 时,进度条将完全加载,这是错误的。 如何根据进度值加载此进度?

谢谢

我注意到您将参数progress声明为int.实际上,你应该将其声明为float,因为进度范围从01。 例如,您可以按如下方式改进代码:

public void ShowProgressBar(string title, string message, int max, int time) //time means the number of you call this method .from 1-18
{
UIViewController controller =
UIApplication.SharedApplication.KeyWindow.RootViewController;
hud = new MTMBProgressHUD(controller.View);
controller.View.AddSubview(hud);
hud.Color = UIColor.Clear.FromHex(0x8BC34A);
hud.Mode = MBProgressHUDMode.DeterminateHorizontalBar;
float progress = time / 18.0f;
hud.Progress = progress;
}

最新更新