UIImageAdditions imageByResizingToSize returns a blank image
nebiros opened this issue · comments
Juan Alvarez commented
UIImageAdditions imageByResizingToSize returns a blank image, here's my code:
#import <FoundationExtension/UIImageAdditions.h>
...
UIImage *compassImage = [UIImage imageNamed:@"compass.png"];
UIImage *compassImageThumb = [compassImage imageByResizingToSize:CGSizeMake(20.0, 20.0)];
UIBarButtonItem *compassButtonItem = [[UIBarButtonItem alloc] initWithImage:compassImageThumb style:UIBarButtonItemStyleBordered target:self action:@selector(compassButtonPressed:)];
self.navigationItem.rightBarButtonItem = compassButtonItem;
This is what I got:
The compass.png
image:
BTW, using UIGraphicsBeginImageContext
to resize the image using a CGSize
works!, the code:
UIImage *compassImage = [UIImage imageNamed:@"compass.png"];
CGSize newSize = CGSizeMake(20.0, 20.0);
UIGraphicsBeginImageContext(newSize);
[compassImage drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *compassImageThumb = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Jeong, YunWon commented
Thanks! Was it on simulator? I got a report that this works only on device before.
And thank you for the patch code!
Juan Alvarez commented
@youknowone Yes!, on the simulator. No problem, great lib, :).
Jeong, YunWon commented
I replaced the code from yours, thanks ;)
Juan Alvarez commented
@youknowone cool!, 👍