-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIDevice+Convenience.swift
More file actions
68 lines (57 loc) · 2.47 KB
/
UIDevice+Convenience.swift
File metadata and controls
68 lines (57 loc) · 2.47 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// UIDevice+Convenience.swift
//
// Created by Marc Stroebel on 2015/01/15.
extension UIDevice {
class func SYSTEM_VERSION_EQUAL_TO(version: NSString) -> Bool {
return self.currentDevice().systemVersion.compare(version as String,
options: NSStringCompareOptions.NumericSearch) == NSComparisonResult.OrderedSame
}
class func SYSTEM_VERSION_GREATER_THAN(version: NSString) -> Bool {
return self.currentDevice().systemVersion.compare(version as String,
options: NSStringCompareOptions.NumericSearch) == NSComparisonResult.OrderedDescending
}
class func SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(version: NSString) -> Bool {
return self.currentDevice().systemVersion.compare(version as String,
options: NSStringCompareOptions.NumericSearch) != NSComparisonResult.OrderedAscending
}
class func SYSTEM_VERSION_LESS_THAN(version: NSString) -> Bool {
return self.currentDevice().systemVersion.compare(version as String,
options: NSStringCompareOptions.NumericSearch) == NSComparisonResult.OrderedAscending
}
class func SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(version: NSString) -> Bool {
return self.currentDevice().systemVersion.compare(version as String,
options: NSStringCompareOptions.NumericSearch) != NSComparisonResult.OrderedDescending
}
class func isIPad() -> Bool {
return UIDevice.currentDevice().userInterfaceIdiom == .Pad
}
class func isIPhone4() -> Bool {
if #available(iOS 8.0, *) {
return UIScreen.mainScreen().nativeBounds.size.height < 1136
} else {
return UIScreen.mainScreen().bounds.size.height < 568
}
}
class func isIPhone5() -> Bool {
if #available(iOS 8.0, *) {
return UIScreen.mainScreen().nativeBounds.size.height == 1136
} else {
return UIScreen.mainScreen().bounds.size.height == 568
}
}
class func isIPhone6() -> Bool {
if #available(iOS 8.0, *) {
return UIScreen.mainScreen().nativeBounds.size.height == 1334
} else {
return UIScreen.mainScreen().bounds.size.height == 667
}
}
class func isIPhone6Plus() -> Bool {
if #available(iOS 8.0, *) {
return UIScreen.mainScreen().nativeBounds.size.height == 1472
} else {
return UIScreen.mainScreen().bounds.size.height == 736
}
}
}