Avoid generating zero size bitmaps

This commit is contained in:
James Magahern
2023-04-14 19:37:31 -07:00
parent 748023d330
commit f8d19414d5
3 changed files with 8 additions and 2 deletions

View File

@@ -31,8 +31,9 @@ class GradientView: UIImageView
}
private func gradientImage(forSize size: CGSize) -> UIImage? {
var image: UIImage? = nil
guard size != .zero else { return nil }
var image: UIImage? = nil
UIGraphicsBeginImageContext(size)
if let context = UIGraphicsGetCurrentContext() {
let gradientColorsArray = self.colors.map { $0.cgColor }