mirror of
https://github.com/hyperoslo/Cache.git
synced 2026-04-07 19:17:36 +00:00
19 lines
511 B
Swift
19 lines
511 B
Swift
#if canImport(UIKit)
|
|
import UIKit
|
|
|
|
extension TestHelper {
|
|
static func image(_ color: UIColor = .red, size: CGSize = .init(width: 1, height: 1)) -> UIImage {
|
|
UIGraphicsBeginImageContextWithOptions(size, false, 0)
|
|
|
|
let context = UIGraphicsGetCurrentContext()
|
|
context?.setFillColor(color.cgColor)
|
|
context?.fill(CGRect(x: 0, y: 0, width: size.width, height: size.height))
|
|
|
|
let image = UIGraphicsGetImageFromCurrentImageContext()
|
|
UIGraphicsEndImageContext()
|
|
|
|
return image!
|
|
}
|
|
}
|
|
#endif
|