From aa30514b30f669979eafa1a1d437d75c5f485034 Mon Sep 17 00:00:00 2001 From: Ivan Magda Date: Sat, 16 Sep 2023 15:51:19 +0400 Subject: [PATCH] Fix crash in AvatarImageView.renderImage(with:) (#1173) --- Stepic/Legacy/Views/AvatarImageView.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Stepic/Legacy/Views/AvatarImageView.swift b/Stepic/Legacy/Views/AvatarImageView.swift index 28914cc39f..bf58c7214e 100644 --- a/Stepic/Legacy/Views/AvatarImageView.swift +++ b/Stepic/Legacy/Views/AvatarImageView.swift @@ -93,6 +93,10 @@ final class AvatarImageView: UIImageView { label.textAlignment = NSTextAlignment.center label.backgroundColor = UIColor(hex6: self.colors[letters.hash % self.colors.count]) + if label.bounds.size == .zero { + return nil + } + let scale = UIScreen.main.scale UIGraphicsBeginImageContextWithOptions(label.bounds.size, false, scale) if let context = UIGraphicsGetCurrentContext() {