IOS Extension Extension Resize Preview Using Swift

In the iOS Share Extension, you can capture a preview image using loadPreviewImageWithOptions. Can I resize a preview image?

The preview image is a screenshot of the website. I am wondering if it is possible to get a screenshot with the original size.

As indicated, a dictionary can be created for parameters.

https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSItemProvider_Class/index.html#//apple_ref/doc/constant_group/Options_Dictionary_Key

For this reason, I use the following code (trying with different values).

let options: [String: NSValue] = [NSItemProviderPreferredImageSizeKey: NSValue(CGSize: CGSizeMake(375.0, 600.0))] itemProvider.loadPreviewImageWithOptions(options, completionHandler: { [ weak self ] image, error in if let image = image as? UIImage { } }) 

But the result is always an 84 x 79 image

Thanks!

+5
source share

Source: https://habr.com/ru/post/1243431/


All Articles