[英]MBProgressHUD horizontal progress bar 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次。 首次調用此方法時,進度條將完全加載,這是錯誤的。 如何根據進度值加載此進度?
謝謝
我注意到您將參數progress
聲明為int
。實際上,您應該將其聲明為float
,因為progress的范圍是0
到1
。 例如,您可以按以下方式改進代碼:
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.