苹果自带分享的页面,非常轻便和简单,不用导入庞大的第三方库,日常使用中,基本上是满足需求的,分享到微信好友,朋友圈,微博,qq空间,qq好友,微信和qq的收藏以及邮件,信息,airDrop ,备忘录等等
示例
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// 按钮
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(100, 100, 200, 200);
btn.backgroundColor = [UIColor orangeColor];
[btn setTitle:@"Activity" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(activity) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:btn];
}
#pragma activity方法
- (void)activity{
// 文字
NSString *str = @"这是activity";
// 链接
NSURL *URL = [NSURL URLWithString:@"http://www.baidu.com"];
// 创建UIActivityViewController
// ActivityItems参数
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[str, URL] applicationActivities:nil];
// 不显示的activity
activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook];
[self presentViewController:activityVC animated:YES completion:nil];
}
@end
```![![1551677045515_.pic.jpg](https://upload-images.jianshu.io/upload_images/3704739-4ae32206e3022fc6.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
](https://upload-images.jianshu.io/upload_images/3704739-d42b7b8ec9783a0b.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)