This repository was archived by the owner on Sep 19, 2024. It is now read-only.
File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import UIKit
12
12
@available ( iOS 11 . 0 , * )
13
13
@available ( tvOS 11 . 0 , * )
14
14
public extension UIColor {
15
+
16
+ #if os(iOS) || os(tvOS)
15
17
/**
16
18
Returns the color from this resource (R.color.*) that is compatible with the trait collection.
17
19
@@ -23,4 +25,19 @@ public extension UIColor {
23
25
public convenience init ? ( resource: ColorResourceType , compatibleWith traitCollection: UITraitCollection ? = nil ) {
24
26
self . init ( named: resource. name, in: resource. bundle, compatibleWith: traitCollection)
25
27
}
28
+ #endif
29
+
30
+ #if os(watchOS)
31
+ /**
32
+ Returns the color from this resource (R.color.*) that is compatible with the trait collection.
33
+
34
+ - parameter resource: The resource you want the image of (R.color.*)
35
+
36
+ - returns: A color that exactly or best matches the desired traits with the given resource (R.color.*), or nil if no suitable color was found.
37
+ */
38
+ @available ( watchOSApplicationExtension 4 . 0 , * )
39
+ public convenience init ? ( resource: ColorResourceType ) {
40
+ self . init ( named: resource. name)
41
+ }
42
+ #endif
26
43
}
Original file line number Diff line number Diff line change 10
10
import UIKit
11
11
12
12
public extension UIImage {
13
+
14
+ #if os(iOS) || os(tvOS)
13
15
/**
14
16
Returns the image from this resource (R.image.*) that is compatible with the trait collection.
15
17
@@ -21,4 +23,18 @@ public extension UIImage {
21
23
public convenience init ? ( resource: ImageResourceType , compatibleWith traitCollection: UITraitCollection ? = nil ) {
22
24
self . init ( named: resource. name, in: resource. bundle, compatibleWith: traitCollection)
23
25
}
26
+ #endif
27
+
28
+ #if os(watchOS)
29
+ /**
30
+ Returns the image from this resource (R.image.*) that is compatible with the trait collection.
31
+
32
+ - parameter resource: The resource you want the image of (R.image.*)
33
+
34
+ - returns: An image that exactly or best matches the desired traits with the given resource (R.image.*), or nil if no suitable image was found.
35
+ */
36
+ public convenience init ? ( resource: ImageResourceType ) {
37
+ self . init ( named: resource. name)
38
+ }
39
+ #endif
24
40
}
You can’t perform that action at this time.
0 commit comments