sharingService(_:transitionImageForShareItem:contentRect:)
Invoked to allow returning a custom transition image when sharing an item.
Declaration
@MainActor optional func sharingService(_ sharingService: NSSharingService, transitionImageForShareItem item: Any, contentRect: UnsafeMutablePointer<NSRect>) -> NSImage?Parameters
- sharingService:
The sharing service.
- item:
The shared item.
- contentRect:
The content rectangle is the frame of the actual content inside the transition image, excluding all decorations. For example, if the transition image is a QuickLook thumbnail, the value would be
QLThumbnailGetContentRect.
Return Value
The image to display for the sharing transition. Its size should exactly match that of the original image.
Discussion
A sample implementation of this method:
- (NSImage *)sharingService:(NSSharingService *)sharingService
transitionImageForShareItem:(id <NSPasteboardWriting>)item
contentRect:(NSRect *)contentRect
{
if ([item isKindOfClass:[NSImage class]]) {
return [_imageView image];
}
}