2016-06-13 3 views
0

私のアプリケーションでは、カスタムUIActivityIndi​​catorビュー(this)を使用しています。 私はUITableViewを持っており、データをロードする際に、テーブルビュー上にインジケータが必要です。この問題を解決するために、何よりもバックグラウンドのある空のビューを作成し、インジケータのアニメーションを開始する必要があるときは、単純にテーブルビューを非表示にし、空のビュー+インジケータを表示します。UIActivityIndi​​catorViewダイアログボックスの表示

Image 2

私はどのように操作を行うことができます。私は私ではなく、このようなものを使用することができることをどこかで見た

Image 1

結果がこれですか?

ありがとうございます。

+0

あなたは薄暗い背景を意味ですか? –

+0

'NVActivityIndi​​catorViewable'はあなたのために機能しませんか? – srvv

+0

@SonLeはい私はそれが私が探しているものだと思います – Jigen

答えて

1

テーブルビュー上に半透明の黒色のビューを追加し、黒色のビューにカスタムアクティビティインジケータコードをサブビューとして追加することができます。もしあなたの要求を終了すれば

let aBlackView = UIView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height)) 
aBlackView.backgroundColor = UIColor.blackColor() 
aBlackView.alpha = 0.75 // Change the alpha depending on how much transparency you require 

let aMainWindow = UIApplication.sharedApplication().delegate!.window 
aMainWindow!!.addSubview(aBlackView) 

/* Enter you code for NVActivityIndicatorViewable here */ 

aBlackView.addSubview(/* NVActivityIndicatorViewable */) 

、あなたはこのコードを呼び出すことにより、黒表示を削除することができます。

aBlackView.removeFromSuperview() 
1

は私が画面を示すアクティビティを作成しました。私は私のプロジェクトのどこにいても使っていました。

//ProgressBarNotification.swift

import Foundation 
import UIKit 

class ProgressBarNotification { 

internal static var strLabel = UILabel() 
internal static var messageFrame = UIView() 
internal static var activityIndicator = UIActivityIndicatorView()  

internal static func progressBarDisplayer(msg:String,indicator:Bool){ 


    let view1 = UIApplication.sharedApplication().delegate?.window!!.rootViewController?.view 

    view1?.userInteractionEnabled = false 

    strLabel = UILabel(frame: CGRect(x: 50, y: 0, width: 200, height: 50)) 
    strLabel.text = msg 
    strLabel.textColor = UIColor.whiteColor() 
    messageFrame = UIView(frame: CGRect(x: view1!.frame.midX - 90, y: view1!.frame.midY - 25 , width: 180, height: 50)) 
    messageFrame.layer.cornerRadius = 15 
    messageFrame.backgroundColor = UIColor(white: 0, alpha: 0.7) 
    if indicator { 
     activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White) 
     activityIndicator.frame = CGRect(x: 0, y: 0, width: 50, height: 50) 
     activityIndicator.startAnimating() 
     messageFrame.addSubview(activityIndicator) 
    } 
    messageFrame.addSubview(strLabel) 
    view1!.addSubview(messageFrame) 


} 

internal static func removeProgressBar() { 

    let view1 = UIApplication.sharedApplication().delegate?.window!!.rootViewController?.view 

    _ = view1?.subviews.filter({ (view) -> Bool in 
     if view == ProgressBarNotification.messageFrame { 
      view.removeFromSuperview() 
     } 
     return false 
    }) 

    ProgressBarNotification.messageFrame.removeFromSuperview() 

    view1?.userInteractionEnabled = true 

} 

    deinit{ 

    } 
} 

使用

//To start Loader 

    ProgressBarNotification.progressBarDisplayer("Loading", indicator: true) 

    //Stop 

    ProgressBarNotification.removeProgressBar() 
関連する問題