- Xcode 8.0+
- iOS 8.3+
WARNING : It's not work on simulator. #1
You can use CocoaPods to install EFInternetIndicator
by adding it to your Podfile
:
use_frameworks!
pod 'EFInternetIndicator'
To run the example project, clone the repo, and run pod install
from the Example directory first.
To start monitoring internet status in a single UIViewController you just need add the InternetStatusIndicable
protocol and start monitoring with startMonitoringInternet()
import UIKit
import EFInternetIndicator
class ViewController: UIViewController, InternetStatusIndicable {
var internetConnectionIndicator:InternetViewIndicator?
override func viewDidLoad() {
super.viewDidLoad()
self.startMonitoringInternet()
}
}
Also, you can customize indicator using custom parameters:
func startMonitoringInternet(backgroundColor:UIColor, style: MessageView.Layout, textColor:UIColor, message:String, remoteHostName: String)
If you want all yours UIViewControllers monitoring internet you can create a abstract class like:
import UIKit
import EFInternetIndicator
class EFViewController: UIViewController, InternetStatusIndicable {
var internetConnectionIndicator:InternetViewIndicator?
override func viewDidLoad() {
super.viewDidLoad()
self.startMonitoringInternet()
}
}
class SecondViewController: EFViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
// Override properties when you want
class MagicViewController: EFViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.startMonitoringInternet(backgroundColor:UIColor.blue, style: .StatusLine, textColor:UIColor.white, message:"No magic on internet here :(", remoteHostName: "magic.com")
}
}
ezefranca, ezequiel.ifsp@gmail.com
- @SwiftKickMobile for SwiftMessages;
- @ashleymills for Reachability.swift;
EFInternetIndicator is available under the MIT license. See the LICENSE file for more info.