-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkLabel.swift
40 lines (34 loc) · 1002 Bytes
/
NetworkLabel.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// TemperatureView.swift
// MinimalistStatusBar
//
// Created by Daniel Vebman on 8/14/17.
// Copyright © 2017 Daniel Vebman. All rights reserved.
//
import Foundation
import UIKit
class NetworkLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
textAlignment = .right
font = UIFont(name: "FontAwesome", size: 15)
update()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func getNetworkStatusIcon() -> String {
let status = Reachability()?.currentReachabilityStatus
switch status! {
case Reachability.NetworkStatus.reachableViaWiFi:
return "\u{f1eb}"
case Reachability.NetworkStatus.reachableViaWWAN:
return "\u{f012}"
case Reachability.NetworkStatus.notReachable:
return "\u{f05c}"
}
}
func update() {
text = getNetworkStatusIcon()
}
}