Posts

Post not yet marked as solved
30 Replies
So I'mon iOS 16.3 and this issue seems to still be here. Did anyone find any solution to this?
Post not yet marked as solved
9 Replies
I found the only way to get this to work per view is to wrap your rootView in a HostingController like: class HostingController<ContentView>: UIHostingController<ContentView> where ContentView : View {          init(view: ContentView) {         super.init(rootView: view)         NotificationCenter.default.addObserver(forName: .onDarkStatusBar, object: nil, queue: .main) { _ in             self.statusBarEnterDarkBackground()         }                  NotificationCenter.default.addObserver(forName: .onLightStatusBar, object: nil, queue: .main) { _ in             self.statusBarEnterLightBackground()         }                  NotificationCenter.default.addObserver(forName: .onShowStatusBar, object: nil, queue: .main) { _ in             self.statusBarShow()         }                  NotificationCenter.default.addObserver(forName: .onHideStatusBar, object: nil, queue: .main) { _ in             self.statusBarHide()         }     }          @objc required dynamic init?(coder aDecoder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }          private var isDarkContentBackground = false     private var isStatusBarHiden = false     func statusBarEnterDarkBackground() {         isDarkContentBackground = false         setNeedsStatusBarAppearanceUpdate()     }     func statusBarEnterLightBackground() {         isDarkContentBackground = true         setNeedsStatusBarAppearanceUpdate()     }          func statusBarHide() {         isStatusBarHiden = true         setNeedsStatusBarAppearanceUpdate()     }     func statusBarShow() {         isStatusBarHiden = false         setNeedsStatusBarAppearanceUpdate()     }     override var preferredStatusBarStyle: UIStatusBarStyle {         if isDarkContentBackground {             return .lightContent         }         else         {             return .darkContent         }     }          override var prefersStatusBarHidden: Bool {       return isStatusBarHiden     } } Use as let window = UIWindow(windowScene: windowScene)             window.rootViewController = HostingController(view: contentView) Then send out a notification from onDissapear and onAppear. extension Notification.Name {   static let onDarkStatusBar = Notification.Name("onDarkStatusBar")     static let onLightStatusBar = Notification.Name("onLightStatusBar")     static let onHideStatusBar = Notification.Name("onHideStatusBar")     static let onShowStatusBar = Notification.Name("onShowStatusBar") } Using                             .onAppear {                                 NotificationCenter.default.post(name: Notification.Name.onHideStatusBar, object: nil)                             }                             .onDisappear {                                 NotificationCenter.default.post(name: Notification.Name.onShowStatusBar, object: nil)                             }
Post not yet marked as solved
2 Replies
I wonder the same. A google search doesn't come up with much.
Post not yet marked as solved
1 Replies
Turns out you need to add ASWebAuthenticationPresentationContextProviding. if #available(iOS 13.0, *) { self.webAuthSession?.presentationContextProvider = self }Then have your class conform to ASWebAuthenticationPresentationContextProviding by doing.extension MyClass: ASWebAuthenticationPresentationContextProviding { @available(iOS 13.0, *) func presentationAnchor(for session: ASWebAuthenticationSession) -&gt; ASPresentationAnchor { return UIApplication.shared.keyWindow! } }