Skip to content

Commit

Permalink
U 适配iOS13的windowScene
Browse files Browse the repository at this point in the history
U 适配iOS13的windowScene
  • Loading branch information
DamonHu committed Apr 2, 2020
1 parent 296e855 commit dc1e8e9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HDWindowLoggerSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'HDWindowLoggerSwift'
s.swift_version = '5.0'
s.version = '1.2.12'
s.version = '1.2.13'
s.license= { :type => "MIT", :file => "LICENSE" }
s.summary = 'The iOS side displays the output log log on the screen, and can generate log file sharing, which is convenient for debugging information'
s.homepage = 'https://github.com/DamonHu/HDWindowLoggerSwift'
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,26 @@ public class HDWindowLoggerSwift: UIWindow, UITableViewDataSource, UITableViewDe
public static var mCompleteLogOut = true //是否完整输出日志文件名等调试内容
public static var mDebugAreaLogOut = true //是否在xcode底部的调试栏同步输出内容
public static var mPrivacyPassword = "" //解密隐私数据的密码,默认为空不加密
public static let defaultWindowLogger = HDWindowLoggerSwift(frame: CGRect.zero)
public private(set) var mLogDataArray = [HDWindowLoggerItem]()
public static var defaultWindowLogger: HDWindowLoggerSwift {
struct DefaultWindow {
static let kWindowLogger: HDWindowLoggerSwift = { () -> HDWindowLoggerSwift in
if #available(iOS 13.0, *) {
print(UIApplication.shared.connectedScenes)
let windowScene = UIApplication.shared
.connectedScenes
.first
if let windowScene = windowScene as? UIWindowScene {
return HDWindowLoggerSwift(windowScene: windowScene)
}

}
return HDWindowLoggerSwift(frame: CGRect.zero)

}()
}
return DefaultWindow.kWindowLogger
}

//密码解锁是否正确
fileprivate var mPasswordCorrect: Bool {
Expand Down Expand Up @@ -316,6 +334,9 @@ public class HDWindowLoggerSwift: UIWindow, UITableViewDataSource, UITableViewDe
var statusBarHeight: CGFloat = 0
if #available(iOS 13.0, *) {
statusBarHeight = self.windowScene?.statusBarManager?.statusBarFrame.size.height ?? 0
if statusBarHeight == 0 {
statusBarHeight = UIApplication.shared.statusBarFrame.size.height
}
} else {
statusBarHeight = UIApplication.shared.statusBarFrame.size.height
}
Expand All @@ -333,6 +354,23 @@ public class HDWindowLoggerSwift: UIWindow, UITableViewDataSource, UITableViewDe
super.init(coder: coder)
}

@available(iOS 13.0, *)
public override init(windowScene: UIWindowScene) {
super.init(windowScene: windowScene)
DispatchQueue.main.async {
var statusBarHeight: CGFloat = self.windowScene?.statusBarManager?.statusBarFrame.size.height ?? 0
if statusBarHeight == 0 {
statusBarHeight = UIApplication.shared.statusBarFrame.size.height
}
self.frame = CGRect(x: 0, y: statusBarHeight, width: UIScreen.main.bounds.size.width, height: 342)
self.rootViewController = UIViewController()
self.windowLevel = UIWindow.Level.alert
self.backgroundColor = UIColor.clear
self.isUserInteractionEnabled = true
self.createUI()
self.p_bindClick()
}
}

private func createUI() {
self.rootViewController?.view.addSubview(self.mBGView)
Expand Down

0 comments on commit dc1e8e9

Please sign in to comment.