Skip to content

Commit 243fa75

Browse files
committed
Restore key window on dismissal
1 parent f7297cc commit 243fa75

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 8.0.5
5+
6+
### FeaturesFixes
7+
8+
* #446 Restore previous key window on dismissal if the message assumed key window status.
9+
410
## 8.0.4
511

612
### Features

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
SwiftMessages is a very flexible view and view controller presentation library for iOS.
1616

17-
Message views and view controllers can be displayed at the top, bottom, or center of the screen, over or under the status bar, or behind navigation bars and tab bars. There are interactive dismiss gestures including a fun, physics-based one. Multiple background dimming modes. And a lot more!
17+
Message views and view controllers can be displayed at the top, bottom, or center of the screen, or behind navigation bars and tab bars. There are interactive dismiss gestures including a fun, physics-based one. Multiple background dimming modes. And a lot more!
1818

1919
In addition to the numerous configuration options, SwiftMessages provides several good-looking layouts and themes. But SwiftMessages is also designer-friendly, which means you can fully and easily customize the view:
2020

@@ -135,10 +135,13 @@ var config = SwiftMessages.Config()
135135
// Slide up from the bottom.
136136
config.presentationStyle = .bottom
137137

138-
// Display in a window at the specified window level: UIWindow.Level.statusBar
139-
// displays over the status bar while UIWindow.Level.normal displays under.
138+
// Display in a window at the specified window level.
140139
config.presentationContext = .window(windowLevel: .statusBar)
141140

141+
Note that, as of iOS 13, it is no longer possible to cover the status bar
142+
regardless of the window level. A workaround is to hide the status bar instead.
143+
config.prefersStatusBarHidden = true
144+
142145
// Disable the default auto-hiding behavior.
143146
config.duration = .forever
144147

SwiftMessages.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'SwiftMessages'
3-
spec.version = '8.0.4'
3+
spec.version = '8.0.5'
44
spec.license = { :type => 'MIT' }
55
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
66
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }

SwiftMessages/WindowViewController.swift

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import UIKit
1010

1111
open class WindowViewController: UIViewController
1212
{
13-
fileprivate var window: UIWindow?
14-
15-
let windowLevel: UIWindow.Level
16-
let config: SwiftMessages.Config
17-
1813
override open var shouldAutorotate: Bool {
1914
return config.shouldAutorotate
2015
}
@@ -41,6 +36,9 @@ open class WindowViewController: UIViewController
4136
@available(iOS 13, *)
4237
func install(becomeKey: Bool, scene: UIWindowScene?) {
4338
window?.windowScene = scene
39+
if becomeKey {
40+
previousKeyWindow = UIApplication.shared.keyWindow
41+
}
4442
show(becomeKey: becomeKey, frame: scene?.coordinateSpace.bounds)
4543
}
4644

@@ -60,6 +58,7 @@ open class WindowViewController: UIViewController
6058
}
6159
window?.isHidden = true
6260
window = nil
61+
previousKeyWindow?.makeKeyAndVisible()
6362
}
6463

6564
required public init?(coder aDecoder: NSCoder) {
@@ -73,6 +72,15 @@ open class WindowViewController: UIViewController
7372
open override var prefersStatusBarHidden: Bool {
7473
return config.prefersStatusBarHidden ?? super.prefersStatusBarHidden
7574
}
75+
76+
// MARK: - Variables
77+
78+
let windowLevel: UIWindow.Level
79+
80+
private var window: UIWindow?
81+
private weak var previousKeyWindow: UIWindow?
82+
83+
private let config: SwiftMessages.Config
7684
}
7785

7886
extension WindowViewController {

0 commit comments

Comments
 (0)