ProHUD/ProHUD/ProHUD.swift

66 lines
1.4 KiB
Swift
Raw Normal View History

2019-07-31 17:40:39 +08:00
//
// ProHUD.swift
// ProHUD
//
// Created by xaoxuu on 2019/7/23.
// Copyright © 2019 Titan Studio. All rights reserved.
//
import UIKit
2019-08-01 20:22:57 +08:00
public class ProHUD {
2019-07-31 17:40:39 +08:00
public static let shared = ProHUD()
2019-08-03 17:48:37 +08:00
public var config: Configuration {
return cfg
}
2019-07-31 17:40:39 +08:00
}
2019-08-03 17:48:37 +08:00
// MARK: - Utilities
2019-07-31 17:40:39 +08:00
internal extension ProHUD {
2019-08-03 17:48:37 +08:00
/// Bundle
2019-08-01 20:22:57 +08:00
static var bundle: Bundle {
2019-08-08 11:09:22 +08:00
var b = Bundle.init(for: Alert.self)
2019-07-31 17:40:39 +08:00
let p = b.path(forResource: "ProHUD", ofType: "bundle")
if let bb = Bundle.init(path: p ?? "") {
b = bb
}
return b
}
2019-08-05 20:13:17 +08:00
2019-08-03 17:48:37 +08:00
/// Image
2019-08-01 20:22:57 +08:00
static func image(named: String) -> UIImage? {
2019-07-31 17:40:39 +08:00
return UIImage.init(named: named, in: bundle, compatibleWith: nil)
}
}
2019-08-03 16:22:50 +08:00
2019-08-03 17:48:37 +08:00
///
internal var isPortrait: Bool {
if UIDevice.current.userInterfaceIdiom == .phone {
if UIApplication.shared.statusBarOrientation.isPortrait {
debug("当前是手机竖屏模式")
return true
} else {
debug("当前是手机横屏模式")
2019-08-03 16:22:50 +08:00
}
} else {
2019-08-03 17:48:37 +08:00
debug("非手机设备unspecified、iPad、tv、carPlay")
2019-08-03 16:22:50 +08:00
}
2019-08-03 17:48:37 +08:00
return false
2019-08-03 16:22:50 +08:00
}
2019-08-03 17:48:37 +08:00
/// Debug
internal func debug(_ items: Any..., separator: String = " ", terminator: String = "\n") {
if cfg.enableDebugPrint {
debugPrint(items, separator: separator, terminator: terminator)
2019-08-03 16:22:50 +08:00
}
}
2019-08-03 17:48:37 +08:00