2016-07-12 127 views
0

我开始使用Xamarin.iOS进行iOS开发,我想知道是否在iOS中有与Android等效的ProgressDialog?ProgressDialog相当于iOS

换句话说,我想在iOS中创建这样一个模式: enter image description here

回答

2

我认为,

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

是最好的选择。你可以从这里

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

编辑1

找到信息下面是我写的一个静态类。希望能对你有所帮助

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); 
     } 
    } 
} 
+0

用例子更新了答案 – PrafulD

0

This Xamarin.IOS documentation link应该给你你需要建立一个进度对话框的内容。在他们的例子中,进度对话框正在整个屏幕上,但调整了一些参数,你可以使它基本看起来你想要的。

1

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(); } 
     ); 
    } 
} 

enter image description here