Skip to content

Commit

Permalink
Fix build error on watchOS (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgacy authored Jul 3, 2024
1 parent 827e5ea commit 5a60145
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Tests/ImageFetcherTests/Helpers/Extensions/Color+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,23 @@ public typealias Color = UIColor

extension Color {
public func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
#if os(iOS) || os(tvOS)
UIGraphicsImageRenderer(size: size).image { rendererContext in
self.setFill()
rendererContext.fill(CGRect(origin: .zero, size: size))
}
#else
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
defer { UIGraphicsEndImageContext() }

self.setFill()
UIRectFill(CGRect(origin: .zero, size: size))
guard let image = UIGraphicsGetImageFromCurrentImageContext() else {
fatalError("Could not generate image: UIGraphicsGetImageFromCurrentImageContext returned nil.")
}

return image
#endif
}
}
#endif
Expand Down

0 comments on commit 5a60145

Please sign in to comment.