Use modern APIs for accessing key window
Shouldn't be relying on deprecated API. Tsk. Tsk.
This commit is contained in:
parent
7f58422900
commit
4689c8e78f
|
@ -22,5 +22,13 @@ extension UIApplication {
|
||||||
|
|
||||||
return version == build ? "v\(version)" : "v\(version) (\(build))"
|
return version == build ? "v\(version)" : "v\(version) (\(build))"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getKeyWindow() -> UIWindow? {
|
||||||
|
return UIApplication
|
||||||
|
.shared
|
||||||
|
.connectedScenes
|
||||||
|
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
|
||||||
|
.first { $0.isKeyWindow }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,8 @@ extension HomeTimelineViewController {
|
||||||
identifier: nil,
|
identifier: nil,
|
||||||
options: [],
|
options: [],
|
||||||
children: [
|
children: [
|
||||||
UIAction(title: "Toggle Visible Touches", image: UIImage(systemName: "hand.tap"), attributes: []) { [weak self] action in
|
UIAction(title: "Toggle Visible Touches", image: UIImage(systemName: "hand.tap"), attributes: []) { _ in
|
||||||
guard let window = UIApplication.shared.keyWindow as? TouchesVisibleWindow else { return }
|
guard let window = UIApplication.shared.getKeyWindow() as? TouchesVisibleWindow else { return }
|
||||||
window.touchesVisible = !window.touchesVisible
|
window.touchesVisible = !window.touchesVisible
|
||||||
},
|
},
|
||||||
UIAction(title: "Toggle EmptyView", image: UIImage(systemName: "clear"), attributes: []) { [weak self] action in
|
UIAction(title: "Toggle EmptyView", image: UIImage(systemName: "clear"), attributes: []) { [weak self] action in
|
||||||
|
|
Loading…
Reference in New Issue