Skip to content

Commit

Permalink
Fix crash in AvatarImageView.renderImage(with:) (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda authored Sep 16, 2023
1 parent 2c94c01 commit aa30514
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Stepic/Legacy/Views/AvatarImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit aa30514

Please sign in to comment.