Skip to content

Commit c90e359

Browse files
committed
fix: 防止UIGraphicsBeginImageContextWithOptions闪退
1 parent 368d283 commit c90e359

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

NIMKit/NIMKit/Classes/Category/UIImage+NIMKit.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ - (UIImage *)nim_cropedImageWithSize:(CGSize)targetSize
290290
{
291291
return self;
292292
}
293+
294+
if (targetSize.width <= 0 || targetSize.height <= 0) {
295+
return self;
296+
}
293297

294298
if (targetSize.width / targetSize.height > sourceSize.width / sourceSize.height)
295299
{

NIMKit/NIMKit/Classes/Sections/Common/NIMAvatarImageView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ - (void)setImage:(UIImage *)image
101101

102102
- (UIImage*)imageAddCorner:(UIImage *)image radius:(CGFloat)radius andSize:(CGSize)size
103103
{
104+
if (size.width <= 0 || size.height <= 0) {
105+
return NULL;
106+
}
104107
CGRect rect = CGRectMake(0, 0, size.width, size.height);
105108

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

0 commit comments

Comments
 (0)