Skip to content

Commit

Permalink
fix: 防止UIGraphicsBeginImageContextWithOptions闪退
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Jan 9, 2024
1 parent 368d283 commit c90e359
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NIMKit/NIMKit/Classes/Category/UIImage+NIMKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ - (UIImage *)nim_cropedImageWithSize:(CGSize)targetSize
{
return self;
}

if (targetSize.width <= 0 || targetSize.height <= 0) {
return self;
}

if (targetSize.width / targetSize.height > sourceSize.width / sourceSize.height)
{
Expand Down
3 changes: 3 additions & 0 deletions NIMKit/NIMKit/Classes/Sections/Common/NIMAvatarImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ - (void)setImage:(UIImage *)image

- (UIImage*)imageAddCorner:(UIImage *)image radius:(CGFloat)radius andSize:(CGSize)size
{
if (size.width <= 0 || size.height <= 0) {
return NULL;
}
CGRect rect = CGRectMake(0, 0, size.width, size.height);

UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
Expand Down

0 comments on commit c90e359

Please sign in to comment.