|
@@ -132,16 +132,6 @@ func delay(by delayTime: TimeInterval, qosClass: DispatchQoS.QoSClass? = nil,
|
|
|
dispatchQueue.asyncAfter(deadline: DispatchTime.now() + delayTime, execute: closure)
|
|
|
}
|
|
|
|
|
|
-func getCurrentVC() -> UIViewController? {
|
|
|
- let keywindow = (UIApplication.shared.delegate as? AppDelegate)?.window
|
|
|
- let firstView: UIView? = keywindow?.subviews.first
|
|
|
- let secondView: UIView? = firstView?.subviews.first
|
|
|
- var vc = viewForController(view: secondView)
|
|
|
- vc = ((vc as? UITabBarController)?.selectedViewController as? UINavigationController)?.visibleViewController
|
|
|
-
|
|
|
- return vc
|
|
|
-}
|
|
|
-
|
|
|
private func viewForController(view:UIView?)->UIViewController?{
|
|
|
var next:UIView? = view
|
|
|
repeat{
|
|
@@ -153,58 +143,6 @@ private func viewForController(view:UIView?)->UIViewController?{
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//classType: 当前页面类类型
|
|
|
-func vcResult(classType: UIViewController.Type) -> Bool {
|
|
|
- return (getCurrentVC()?.isKind(of: classType))!
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-///获取当前显示的控制器 UIWindow (Visible)
|
|
|
-func getCurrentVC2() -> UIViewController {
|
|
|
- let keywindow = (UIApplication.shared.delegate as! AppDelegate).window?.rootViewController//UIApplication.shared.keyWindow
|
|
|
- let rootVC = keywindow!//UIApplication.shared.keyWindow!.rootViewController!
|
|
|
- return getVisibleViewControllerFrom(vc: rootVC)
|
|
|
-}
|
|
|
-
|
|
|
-//方法1
|
|
|
-func getVisibleViewControllerFrom(vc: UIViewController) -> UIViewController {
|
|
|
-
|
|
|
- if vc.isKind(of: UINavigationController.self) {
|
|
|
- return getVisibleViewControllerFrom(vc: (vc as! UINavigationController).visibleViewController!)
|
|
|
- } else if vc.isKind(of: UITabBarController.self) {
|
|
|
- return getVisibleViewControllerFrom(vc: (vc as! UITabBarController).selectedViewController!)
|
|
|
- } else {
|
|
|
- if (vc.presentedViewController != nil) {
|
|
|
- return getVisibleViewControllerFrom(vc: vc.presentedViewController!)
|
|
|
- } else {
|
|
|
- return vc
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-//方法2
|
|
|
-func topViewControllerWithRootViewController(rootVC: UIViewController) -> UIViewController {
|
|
|
-
|
|
|
- if rootVC.isKind(of: UITabBarController.self) {
|
|
|
- let tabVC = rootVC as! UITabBarController
|
|
|
- return topViewControllerWithRootViewController(rootVC: tabVC.selectedViewController!)
|
|
|
- } else if rootVC.isKind(of: UINavigationController.self) {
|
|
|
- let navc = rootVC as! UINavigationController
|
|
|
- return topViewControllerWithRootViewController(rootVC: navc.visibleViewController!)
|
|
|
- } else if (rootVC.presentedViewController != nil) {
|
|
|
- return topViewControllerWithRootViewController(rootVC: rootVC.presentedViewController!)
|
|
|
- } else {
|
|
|
- return rootVC
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-///验证
|
|
|
-func vcResult2(classType: UIViewController.Type) -> Bool {
|
|
|
- return getCurrentVC2().isKind(of: classType)
|
|
|
-}
|
|
|
-
|
|
|
func showSwiftProgressHUDInfo() {
|
|
|
SwiftProgressHUD.shared().showText("该功能暂未开通,敬请期待!!!")
|
|
|
}
|
|
@@ -312,33 +250,6 @@ func getImageHeight(imgStr:String) -> CGFloat {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/// 获取缩略图
|
|
|
-///
|
|
|
-/// - Parameters:
|
|
|
-/// - imgStr: 图片地址
|
|
|
-/// - width: 宽度
|
|
|
-/// - height: 高度
|
|
|
-/// - Returns: 返回图片地址
|
|
|
-func getImageUrlStr(imgStr:String,width:CGFloat,height:CGFloat) -> String {
|
|
|
- if imgStr.contains("*") {
|
|
|
- let imgStr1 = imgStr + "?x-oss-process=image/resize,m_fill,w_\(Int(width*1.5)),h_\(Int(height*1.5))"
|
|
|
-// NXLLog(imgStr1)
|
|
|
- return String(imgStr1)
|
|
|
- }else {
|
|
|
- if imgStr.contains("?") {
|
|
|
- var imgStr1 = imgStr.prefix(upTo:(imgStr.lastIndex(of: "?"))!)
|
|
|
- imgStr1 = imgStr1 + "?x-oss-process=image/resize,m_fill,w_\(Int(width*1.5)),h_\(Int(height*1.5))"
|
|
|
-// NXLLog(imgStr1)
|
|
|
-
|
|
|
- return String(imgStr1)
|
|
|
- }else {
|
|
|
- let imgStr1 = imgStr + "?x-oss-process=image/resize,m_fill,w_\(Int(280 * 1.5 * kScaleWidth)),h_\(Int(280 * 1.5 * kScaleWidth))"
|
|
|
-// NXLLog(imgStr1)
|
|
|
- return String(imgStr1)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
/// url字符串转字典
|
|
|
///
|
|
|
/// - Parameter urlString: urlString字符串
|