StatusBarOverlay
  • October 3, 2023

StatusBarOverlay will automatically show a “No Internet Connection” bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

Features


  • Just a few lines of code and StatusBarOverlay will automatically show & hide when internet connection is lost & regained
  • Support for apps that hide the status bar permanently
  • Support for the iPhone X Notch
  • Optionally you can choose to show the status bar anytime with custom text, eg for Debug or Demo modes
  • Optionally you can show a drop down message, below the status bar, with a click handle, great for nonintrusive alerts
  • Fully customisable colors & text

How to install


Add this to your CocoaPods Podfile

pod ‘StatusBarOverlay’

How to use


In your Info.plist file set UIViewControllerBasedStatusBarAppearance = true

In your AppDelegate.didFinishLaunchingWithOptions() method set StatusBarOverlay.host to your server domain. StatusBarOverlay will use this to check connectivity

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

StatusBarOverlay.host = “example.com”

return true
}

If you use a common UIViewController subclass, add the following to it. All of view controllers show override these methods, so its best to use a common UIViewController subclass

import StatusBarOverlay // if StatusBarOverlay is in CocoaPod

extension CommonViewController {

override var preferredStatusBarStyle: UIStatusBarStyle {
return StatusBarOverlay.preferredStatusBarStyle
}

override var prefersStatusBarHidden: Bool {
return StatusBarOverlay.prefersStatusBarHidden
}

override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
return StatusBarOverlay.preferredStatusBarUpdateAnimation
}
}

Thats it. Run your app, try turning on and off airplane mode and the No Internet Connection bar will show and hide. On the simulator sometimes the hiding event isnt fired. All devices work normally

Dependencies


  • Reachability is required for the connectivity events

GitHub


View Github

#animation #loadingview #progressbar #swift #uiview
YOU MIGHT ALSO LIKE...
MijickPopups Hero

  Popups Alerts Resizable Sheets Banners

SwiftUI Tooltip

This package provides you with an easy way to show tooltips over any SwiftUI view, since Apple does not provide ...

SimpleToast for SwiftUI

SimpleToast is a simple, lightweight, flexible and easy to use library to show toasts / popup notifications inside iOS or ...

SSToastMessage

Create Toast Views with Minimal Effort in SwiftUI Using SSToastMessage. SSToastMessage enables you to effortlessly add toast notifications, alerts, and ...

ToastUI

A simple way to show toast in SwiftUI   Getting Started • Documentation • Change Log