Apple has deprecated init(image:)
method in MPMediaItemArtwork
in iOS 10.
What is the new alternative.
the class shows interface shows method
I saw this just now and I'm confused too, but I guess this is the right way:
self.remoteArtwork = [[MPMediaItemArtwork alloc] initWithBoundsSize:CGSizeMake(600, 600) requestHandler:^UIImage * _Nonnull(CGSize size) {
UIImage *lockScreenArtworkApp = [UIImage imageNamed:@"lockScreenLogo"];
return [self.manager resizeImageWithImage:lockScreenArtworkApp scaledToSize:size];
}];
The method - in my case in a singleton "Manager"-Class
- (UIImage *)resizeImageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
//UIGraphicsBeginImageContext(newSize);
// In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution).
// Pass 1.0 to force exact pixel size.
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}