我刚刚看到这个,我也很困惑,但我想这是正确的方法:
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];
}];
该方法-在我的情况下是单例“经理”类
- (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;
}