File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import UIKit
1212@available ( iOS 11 . 0 , * )
1313@available ( tvOS 11 . 0 , * )
1414public extension UIColor {
15+
16+ #if os(iOS) || os(tvOS)
1517 /**
1618 Returns the color from this resource (R.color.*) that is compatible with the trait collection.
1719
@@ -23,4 +25,19 @@ public extension UIColor {
2325 public convenience init ? ( resource: ColorResourceType , compatibleWith traitCollection: UITraitCollection ? = nil ) {
2426 self . init ( named: resource. name, in: resource. bundle, compatibleWith: traitCollection)
2527 }
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
2643}
Original file line number Diff line number Diff line change 1010import UIKit
1111
1212public extension UIImage {
13+
14+ #if os(iOS) || os(tvOS)
1315 /**
1416 Returns the image from this resource (R.image.*) that is compatible with the trait collection.
1517
@@ -21,4 +23,18 @@ public extension UIImage {
2123 public convenience init ? ( resource: ImageResourceType , compatibleWith traitCollection: UITraitCollection ? = nil ) {
2224 self . init ( named: resource. name, in: resource. bundle, compatibleWith: traitCollection)
2325 }
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
2440}
You can’t perform that action at this time.
0 commit comments