同步操作将从 兰德网络O2OA平台软件/O2OA 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//// HUDTools.swift// O2Platform//// Created by 程剑 on 2017年6月30日.// Copyright © 2017年 zoneland. All rights reserved.//import Foundationimport MBProgressHUD// keyWindowlet KeyWindow : UIWindow = UIApplication.shared.keyWindow!private var HUDKey = "HUDKey"extension UIViewController{var hud : MBProgressHUD?{get{return objc_getAssociatedObject(self, &HUDKey) as? MBProgressHUD}set{objc_setAssociatedObject(self, &HUDKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)}}fileprivate static var waveView: O2LoadingView?/**显示提示信息(有菊花, 一直显示, 不消失),默认文字"加载中",默认偏移量0- parameter view: 显示在哪个View上- parameter hint: 提示信息- parameter yOffset: y上的偏移量*/func showHud(in view: UIView, hint: String = "加载中...", yOffset:CGFloat? = 0){let HUD = MBProgressHUD(view: view)HUD.label.text = hint//HUD.label.font = UIFontSize(size: 15 * UIRate)//设为false后点击屏幕其他地方有反应HUD.isUserInteractionEnabled = true//HUD内的内容的颜色//HUD.contentColor = UIColor(red:0.82, green:0.82, blue:0.82, alpha:1.00)//View的颜色//HUD.bezelView.color = UIColorHex("000000", 0.7)//style -blur 不透明 -solidColor 透明HUD.bezelView.style = .solidColorHUD.margin = 10.0//偏移量,以center为起点// HUD.offset.y = yOffset ?? 0view.addSubview(HUD)HUD.show(animated: true)hud = HUD}/**显示纯文字提示信息(显示在keywindow上),默认时间2s,默认偏移量0- parameter hint: 提示信息- parameter duration: 持续时间(不填的话, 默认两秒)- parameter yOffset: y上的偏移量*/func showHintInKeywindow(hint: String, duration: Double = 2.0, yOffset:CGFloat? = 0) {let view = KeyWindowlet HUD = MBProgressHUD(view: view)view.addSubview(HUD)HUD.animationType = .zoomOutHUD.isUserInteractionEnabled = falseHUD.bezelView.color = UIColor.blackHUD.contentColor = UIColor.whiteHUD.mode = .textHUD.label.text = hintHUD.show(animated: true)HUD.removeFromSuperViewOnHide = falseHUD.offset.y = yOffset ?? 0HUD.margin = 10.0HUD.hide(animated: true, afterDelay: duration)hud = HUD}/**显示纯文字提示信息,默认时间1.5s,默认偏移量0- parameter view: 显示在哪个View上- parameter hint: 提示信息- parameter duration: 持续时间(不填的话, 默认两秒)- parameter yOffset: y上的偏移量*/func showHint(in view: UIView, hint: String, duration: Double = 1.5, yOffset:CGFloat? = 0) {let HUD = MBProgressHUD(view: view)view.addSubview(HUD)HUD.animationType = .zoomOutHUD.bezelView.color = UIColor.blackHUD.contentColor = UIColor.whiteHUD.mode = .textHUD.label.text = hintHUD.isUserInteractionEnabled = falseHUD.removeFromSuperViewOnHide = falseHUD.show(animated: true)HUD.offset.y = yOffset ?? 0HUD.margin = 10.0HUD.hide(animated: true, afterDelay: duration)hud = HUD}func showSuccess(in view: UIView, hint: String, duration: Double = 1.5, yOffset: CGFloat? = 0){let HUD = MBProgressHUD(view: view)view.addSubview(HUD)HUD.animationType = .zoomOutHUD.mode = .customViewHUD.customView = UIImageView(image: UIImage(named: "ProgressHUD.bundle/progresshud-success.png"))HUD.label.text = hintHUD.isUserInteractionEnabled = falseHUD.removeFromSuperViewOnHide = falseHUD.show(animated: true)HUD.offset.y = yOffset ?? 0HUD.margin = 10HUD.hide(animated: true, afterDelay: duration)hud = HUD}func showError(in view: UIView, hint: String, duration: Double = 1.5, yOffset: CGFloat? = 0){let HUD = MBProgressHUD(view: view)view.addSubview(HUD)HUD.animationType = .zoomOutHUD.mode = .customViewHUD.customView = UIImageView(image: UIImage(named: "ProgressHUD.bundle/progresshud-error.png"))HUD.label.text = hintHUD.isUserInteractionEnabled = falseHUD.removeFromSuperViewOnHide = falseHUD.show(animated: true)HUD.offset.y = yOffset ?? 0HUD.margin = 10HUD.hide(animated: true, afterDelay: duration)hud = HUD}func showLoading(in view: UIView, hint: String, duration: Double = 6, yOffset: CGFloat? = 0){/*let HUD = MBProgressHUD(view: view)view.addSubview(HUD)HUD.animationType = .zoomOutHUD.mode = .customViewlet wv = O2LoadingView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))HUD.customView = wvHUD.label.text = hintHUD.isUserInteractionEnabled = falseHUD.removeFromSuperViewOnHide = falseHUD.show(animated: true)HUD.offset.y = yOffset ?? 0HUD.margin = 10HUD.hide(animated: true, afterDelay: duration)hud = HUDUIViewController.waveView = wv*/let waveV = O2LoadingView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))waveV.center = view.centerview.addSubview(waveV)}/// 移除提示func hideHud() {//如果解包成功则移除,否则不做任何事if let hud = hud {hud.hide(animated: true)}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。