Contents

sharingService(_:sourceFrameOnScreenForShareItem:)

Invoked when the sharing service is performed and the sharing window is displayed, to present a transition between the original items and the sharing window.

Declaration

@MainActor optional func sharingService(_ sharingService: NSSharingService, sourceFrameOnScreenForShareItem item: Any) -> NSRect

Parameters

  • sharingService:

    The sharing service.

  • item:

    The item being shared.

Return Value

The rectangle, in screen coordinates, to display the transition.

Discussion

The following is an example implementation of this method:

- (NSRect)sharingService:(NSSharingService *)sharingService sourceFrameOnScreenForShareItem:(id <NSPasteboardWriting>)item
{
    if ([item isKindOfClass:[NSImage class]]) {
        NSImage * image = [_imageView image];
        NSRect frame = [_imageView bounds];
        frame = [_imageView convertRect:frame toView:nil];
        frame.origin = [[_imageView window] convertBaseToScreen:frame.origin];
        return frame;
    }
    return NSZeroRect;
}

See Also

Customizing Transition Animation