如圖
image.png
有時(shí)候會(huì)提需求說(shuō)要透明等待框,這樣加載時(shí)的等待不引人注意。
之前可以這樣設(shè)置
let mb = MBProgressHUD.showAdded(to: self.view, animated: true)
mb?.backgroundColor = UIColor.clear
mb?.color = UIColor.clear
mb?.activityIndicatorColor = UIColor.blue
mb?.hide(true, afterDelay: 2.0)
這里將等待圈改為了藍(lán)色,因?yàn)槿绻辉O(shè)置默認(rèn)是白色的故硅,太不明顯。
然后我就發(fā)現(xiàn)新的MBProgressHUD這樣設(shè)置沒(méi)用纵搁,找了半天終于找到方法
先設(shè)置hud.bezelView 的style 為MBProgressHUDBackgroundStyleSolidColor吃衅,然后再設(shè)置其背影色就可以了。因?yàn)樗J(rèn)的style 是MBProgressHUDBackgroundStyleBlur诡渴,即不管背影色設(shè)置成什么顏色捐晶,都會(huì)被加上半透明的效果,所以要先改其style妄辩。 還是度娘出的回答惑灵,這里感謝 “晨曦夢(mèng)永不棄”
然后新版本代碼這樣寫(xiě)就可以設(shè)置背景框?yàn)橥该髁? 代碼如下
self.view.backgroundColor = UIColor.white
let mb1 = MBProgressHUD.showAdded(to: self.view, animated: true)
mb1.bezelView.style = .solidColor
mb1.bezelView.backgroundColor = UIColor.clear
mb1.hide(animated: true, afterDelay: 2.0)
分享一下,萬(wàn)一以后自己忘了也有個(gè)記錄眼耀。