MBProgressHUD ব্যবহার করতে CocoaPods দিয়ে ইনস্টল করুন।
cd /projectDirectory pod init open podfile # podfile-এ যোগ করুন: pod 'MBProgressHUD', '~> 1.1.0' pod install
পদ্ধতি ১: viewDidLoad-এ সরাসরি
let indicator = MBProgressHUD.showAdded(to: self.view, animated: true) indicator.label.text = "Indicator" indicator.isUserInteractionEnabled = false indicator.detailsLabel.text = "fetching details" indicator.show(animated: true) // লুকানোর জন্য: MBProgressHUD.hide(for: self.view, animated: true)
পদ্ধতি ২: UIViewController এক্সটেনশন (গ্লোবালি ব্যবহারযোগ্য)
extension UIViewController {
func showIndicator(withTitle title: String, and description: String) {
let indicator = MBProgressHUD.showAdded(to: self.view, animated: true)
indicator.label.text = title
indicator.isUserInteractionEnabled = false
indicator.detailsLabel.text = description
indicator.show(animated: true)
}
func hideIndicator() {
MBProgressHUD.hide(for: self.view, animated: true)
}
}
ফলাফল —
