iOS 的 ProgressDialog 等价物

ProgressDialog equivalent for iOS

我正在使用 Xamarin.iOS 开始开发 iOS,我想知道 iOS 中是否有等效于 android 的 ProgressDialog?

换句话说,我想在 iOS 中创建一个这样的模式:

This Xamarin.IOS documentation link 应该会为您提供构建进度对话框所需的内容。在他们的示例中,进度对话框占据了整个屏幕,但通过调整一些参数,您基本上可以使它看起来像您想要的那样。

Xamarin 已针对此确切视图发布了完整的方法。 https://developer.xamarin.com/recipes/ios/standard_controls/popovers/display_a_loading_message/

public class LoadingOverlay : UIView {

    // control declarations
    UIActivityIndicatorView activitySpinner;
    UILabel loadingLabel;

    public LoadingOverlay (CGRect frame) : base (frame)
    {
        // configurable bits
        BackgroundColor = UIColor.Black;
        Alpha = 0.75f;
        AutoresizingMask = UIViewAutoresizing.All;

        nfloat labelHeight = 22;
        nfloat labelWidth = Frame.Width - 20;

        // derive the center x and y
        nfloat centerX = Frame.Width / 2;
        nfloat centerY = Frame.Height / 2;

        // create the activity spinner, center it horizontall and put it 5 points above center x
        activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
        activitySpinner.Frame = new CGRect (
            centerX - (activitySpinner.Frame.Width / 2) ,
            centerY - activitySpinner.Frame.Height - 20 ,
            activitySpinner.Frame.Width,
            activitySpinner.Frame.Height);
        activitySpinner.AutoresizingMask = UIViewAutoresizing.All;
        AddSubview (activitySpinner);
        activitySpinner.StartAnimating ();

        // create and configure the "Loading Data" label
        loadingLabel = new UILabel(new CGRect (
            centerX - (labelWidth / 2),
            centerY + 20 ,
            labelWidth ,
            labelHeight
            ));
        loadingLabel.BackgroundColor = UIColor.Clear;
        loadingLabel.TextColor = UIColor.White;
        loadingLabel.Text = "Loading Data...";
        loadingLabel.TextAlignment = UITextAlignment.Center;
        loadingLabel.AutoresizingMask = UIViewAutoresizing.All;
        AddSubview (loadingLabel);

    }

    /// <summary>
    /// Fades out the control and then removes it from the super view
    /// </summary>
    public void Hide ()
    {
        UIView.Animate (
            0.5, // duration
            () => { Alpha = 0; },
            () => { RemoveFromSuperview(); }
        );
    }
}

我想,

https://components.xamarin.com/view/mbprogresshud/

是最好的选择。您可以从这里找到信息

https://components.xamarin.com/gettingstarted/mbprogresshud

编辑 1

这是我写的静态class。希望能帮到你

using CoreGraphics;
using MBProgressHUD;
using System;
using System.Collections.Generic;
using System.Text;
using UIKit;
namespace CandyCaneClub.iOS.Helper
{
/*
A generic helper class to show and hide the overlay for running processes on application 
*/
    public class OverlayHelper 
    {
        public static MTMBProgressHUD overlay;
        //Initialize the Overlay with string as a message to show and view on which we suppose to show
        public static MTMBProgressHUD InitOverlay(string message, UIView view)
        {
            overlay = new MTMBProgressHUD(view)
            {
                LabelText = message,
                RemoveFromSuperViewOnHide = true
            };
            overlay.Alpha = 0.75f;
            view.AddSubview(overlay);
            overlay.Show(animated: true);
            return overlay;
        }
        //Hide the overlay 
        public static void HideOverlay()
        {
            if(overlay != null)
            overlay.Hide(animated: true, delay: 2);
        }
    }
}