效果图
直接代码_
NSMutableArray *sharingItems = [NSMutableArray new];
NSString *textToShare = [NSString stringWithFormat:@"%@", text?text:[NSString CFBundleDisplayName]];
NSURL *website = [NSURL URLWithString:url?url:@""];
UIImage *shareImage = image?image:[UIImage imageNamed:@"share_app_icon"];
if (textToShare) {
[sharingItems addObject:textToShare];
}
if (website) {
[sharingItems addObject:website];
}
if (shareImage) {
[sharingItems addObject:shareImage];
}
TUSafariActivity *activity = [[TUSafariActivity alloc] init];//第三方库
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:@[activity]];
// 去掉不显示项
NSArray *excludeActivities = @[UIActivityTypePostToWeibo,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypePostToTencentWeibo,
UIActivityTypeAirDrop,
UIActivityTypeOpenInIBooks,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAssignToContact,
UIActivityTypePrint,
];
activityVC.excludedActivityTypes = excludeActivities;
activityVC.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
dispatch_async(dispatch_get_main_queue(), ^{
});
if (completed)
{
NSLog(@"The Activity: %@ was completed", activityType);
}
else
{
NSLog(@"The Activity: %@ was NOT completed", activityType);
}
};
[self presentViewController:activityVC animated:YES completion:nil];