iOS-全局更改MBProgressHUD设计 [英] iOS - Globally change MBProgressHUD design

查看:362
本文介绍了iOS-全局更改MBProgressHUD设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MBProgressHUD在我的应用程序中加载屏幕.我有26次使用其他HUD的情况.

I use MBProgressHUD for loading screens in my app. I have 26 occurrences where I use a different HUD.

现在,我决定为HUD使用自定义的UIView(动画UIImageView).我想将其应用于我在应用程序中使用的所有HUD,但是自定义HUD的代码长约15行,这绝对不是将代码添加到我的应用程序中每次出现的MBProgressHUD的正确方法.

Now, I've decided to use a customised UIView (an animated UIImageView) for the HUD. I want to apply this to all the HUD's I use in my app, but the code to customise the HUD is about 15 lines long, and it's definitely not the right method to add this code to every single occurrence of a MBProgressHUD in my app.

从这里出发的正确方法是什么?这不是我第一次遇到这样的问题,在该问题上我不确定如何保持代码的简洁和简洁.

What's the right way to go from here? This is not the first time I've run into an issue like this where I'm not sure how to keep my code cleaner and simpler.

推荐答案

一种方法是在AppDelegate中声明微调器,并编写方法showSpinnerhideSpinner,还定义

One way is to declare the spinner in the AppDelegate, and write the methods showSpinner and hideSpinner, and also define a macro to call these spinner methods.

您可以在项目中全局使用此宏.更改应用程序委托中的微调器代码也很容易,而且您无需更改任何内容.

And you can just use this macro globally in your project.It is also easy to change the spinner code in the app delegate and you don't have to change anything.

这篇关于iOS-全局更改MBProgressHUD设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆