JXShareMoneyVc.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. //
  2. // JXShareMoneyVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/20.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXShareMoneyVc.h"
  9. #import "JXShareMCell.h"
  10. #import "UMSocialSnsService.h"
  11. #import "UMSocialSnsPlatformManager.h"
  12. #import "UMSocial.h"
  13. #import "MyButton.h"
  14. //#import <TencentOpenAPI/TencentOAuth.h>
  15. //#import "TencentOpenAPI/QQApiInterface.h"
  16. @interface JXShareMoneyVc ()<UITableViewDataSource,UITableViewDelegate,UMSocialUIDelegate>
  17. @property (nonatomic,weak) UIButton *showBt;
  18. @property (nonatomic,weak) UIButton *yaoqingmaBtn;
  19. @property (nonatomic,weak) UITableView *tableView;
  20. @property (nonatomic,strong) NSMutableArray *dataArr;
  21. @end
  22. @implementation JXShareMoneyVc
  23. - (void)gobackBtn{
  24. //[self.navigationController popViewControllerAnimated:YES];
  25. [g_navigation dismissViewController:self animated:YES];
  26. }
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.view.backgroundColor=[UIColor whiteColor];
  30. _dataArr=[NSMutableArray arrayWithObjects:@"1、扫下放二维码下载“即信”APP",@"2、选择您喜爱的快捷方式登录。(首次登录ID号随便填写,注册平台 账号后再修改绑定)",@"3、选择“购彩”界面,选择“我的账户”——“立即注册”——输入下 方邀请码——根据提示注册您购彩账号",@"4、选择“聊天”界面选择“我”——“我的设置”——“账户与安全” ——将ID号修改为与购彩账号一致",@"5、成功开始体验即信购彩赚钱乐趣!", nil];
  31. UIImageView *backIMG = [[UIImageView alloc]init];
  32. backIMG.image=[UIImage imageNamed:@"BG111"];
  33. backIMG.userInteractionEnabled=YES;
  34. backIMG.frame=self.view.bounds;
  35. [self.view addSubview:backIMG];
  36. [self defineNavBar:@"分享赚钱" andRinghtBtnImg:@"1"];
  37. /*
  38. //头像icon
  39. UIImageView *iconIMG = [[UIImageView alloc]init];
  40. iconIMG.image=[UIImage imageNamed:@"ALOGO_120"];
  41. [backIMG addSubview:iconIMG];
  42. [iconIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.mas_equalTo(JX_SCREEN_TOP);
  44. make.centerX.mas_equalTo(backIMG.mas_centerX);
  45. make.width.mas_equalTo(40);
  46. make.height.mas_equalTo(40);
  47. }];
  48. UILabel *centLabel=[[UILabel alloc]init];
  49. centLabel.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
  50. centLabel.text=@"即信";
  51. centLabel.textColor=kRGBColor(222, 29, 19);
  52. [backIMG addSubview:centLabel];
  53. [centLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.top.mas_equalTo(iconIMG.mas_bottom).mas_offset(15);
  55. make.centerX.mas_equalTo(iconIMG.mas_centerX);
  56. }];
  57. UIImageView *leftIMG = [[UIImageView alloc]init];
  58. leftIMG.image=[UIImage imageNamed:@"xiantiao2"];
  59. [backIMG addSubview:leftIMG];
  60. [leftIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.right.mas_equalTo(centLabel.mas_left).mas_offset(-10);
  62. make.centerY.mas_equalTo(centLabel.mas_centerY);
  63. }];
  64. UIImageView *rightIMG = [[UIImageView alloc]init];
  65. rightIMG.image=[UIImage imageNamed:@"xiantiao1"];
  66. [backIMG addSubview:rightIMG];
  67. [rightIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.mas_equalTo(centLabel.mas_right).mas_offset(10);
  69. make.centerY.mas_equalTo(centLabel.mas_centerY);
  70. }];
  71. */
  72. //搜索框
  73. UIButton *searchBtn = [[UIButton alloc]init];
  74. [searchBtn setBackgroundImage:[UIImage imageNamed:@"sousuo"] forState:UIControlStateNormal];
  75. [backIMG addSubview:searchBtn];
  76. [searchBtn addTarget:self action:@selector(saveBttIMG:) forControlEvents:UIControlEventTouchUpInside];
  77. [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.mas_equalTo(backIMG.mas_top).mas_offset(JX_SCREEN_TOP+10);
  79. make.centerX.mas_equalTo(self.view.mas_centerX);
  80. }];
  81. UIImageView *iconIMG = [[UIImageView alloc]init];
  82. iconIMG.image=[UIImage imageNamed:@"ALOGO_120"];
  83. [backIMG addSubview:iconIMG];
  84. [iconIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.left.mas_equalTo(searchBtn.mas_right).mas_offset(10);
  86. make.centerY.mas_equalTo(searchBtn.mas_centerY);
  87. make.width.mas_equalTo(20);
  88. make.height.mas_equalTo(20);
  89. }];
  90. UIButton *chaBtn = [[UIButton alloc]init];
  91. [chaBtn setImage:[UIImage imageNamed:@"chaz"] forState:UIControlStateNormal];
  92. [searchBtn addSubview:chaBtn];
  93. [chaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.top.mas_equalTo(0);
  95. make.left.mas_equalTo(10);
  96. make.height.mas_equalTo(searchBtn.mas_height);
  97. }];
  98. UILabel *titleURL=[[UILabel alloc]init];
  99. titleURL.font=[UIFont systemFontOfSize:11 weight:UIFontWeightRegular];
  100. titleURL.textColor=kRGBColor(222, 29, 19);
  101. titleURL.numberOfLines=0;
  102. titleURL.text=@"www.7520vip.com";
  103. titleURL.textAlignment=NSTextAlignmentCenter;
  104. [searchBtn addSubview:titleURL];
  105. [titleURL mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.top.mas_equalTo(0);
  107. make.centerX.mas_equalTo(self.view.mas_centerX);
  108. make.height.mas_equalTo(searchBtn.mas_height);
  109. }];
  110. // UILabel *titleL=[[UILabel alloc]init];
  111. // titleL.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
  112. // titleL.textColor=kRGBColor(51, 51, 51);
  113. // titleL.numberOfLines=0;
  114. // titleL.text=@"";
  115. // [backIMG addSubview:titleL];
  116. // [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  117. // make.top.mas_equalTo(searchBtn.mas_bottom).mas_offset(10);
  118. // make.left.mas_equalTo(30);
  119. // make.right.mas_equalTo(-30);
  120. // }];
  121. UITableView *tableView=[[UITableView alloc]init];
  122. tableView.backgroundColor=[UIColor clearColor];
  123. tableView.dataSource=self;
  124. tableView.delegate=self;
  125. //tableView.estimatedRowHeight=100;
  126. tableView.separatorStyle=UITableViewCellSelectionStyleNone;
  127. [backIMG addSubview:tableView];
  128. tableView.tableFooterView=[UIView new];
  129. self.tableView=tableView;
  130. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.top.mas_equalTo(searchBtn.mas_bottom).mas_offset(10);
  132. make.left.mas_equalTo(10);
  133. make.right.mas_equalTo(-10);
  134. make.height.mas_equalTo(200);
  135. }];
  136. //二维码
  137. /**
  138. UIImageView *imageV=[[UIImageView alloc]initWithFrame:CGRectMake(222, 222, 222, 222)];
  139. [self.view addSubview:imageV];
  140. */
  141. UIButton *showBt = [[UIButton alloc]init];
  142. [showBt setImage:[UIImage imageNamed:@"signBackImage"] forState:UIControlStateNormal];
  143. [backIMG addSubview:showBt];
  144. self.showBt=showBt;
  145. [showBt addTarget:self action:@selector(saveBttIMG:) forControlEvents:UIControlEventTouchUpInside];
  146. [showBt mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.top.mas_equalTo(tableView.mas_bottom).mas_offset(10);
  148. make.centerX.mas_equalTo(backIMG.mas_centerX);
  149. make.width.mas_equalTo(150);
  150. make.height.mas_equalTo(150);
  151. }];
  152. UIButton *yaoqBtn = [[UIButton alloc]init];
  153. [yaoqBtn setTitle:@"邀请码:4578912" forState:UIControlStateNormal];
  154. yaoqBtn.layer.cornerRadius=18;
  155. yaoqBtn.layer.masksToBounds=YES;
  156. yaoqBtn.backgroundColor=[UIColor redColor];
  157. [backIMG addSubview:yaoqBtn];
  158. self.yaoqingmaBtn=yaoqBtn;
  159. [yaoqBtn addTarget:self action:@selector(saveBttIMG:) forControlEvents:UIControlEventTouchUpInside];
  160. [yaoqBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.top.mas_equalTo(showBt.mas_bottom).mas_offset(10);
  162. make.centerX.mas_equalTo(showBt.mas_centerX);
  163. make.width.mas_equalTo(200);
  164. make.height.mas_equalTo(36);
  165. }];
  166. UIButton *qCoerBtn = [[UIButton alloc]init];
  167. [qCoerBtn setImage:[UIImage imageNamed:@"mageshouji"] forState:UIControlStateNormal];
  168. [backIMG addSubview:qCoerBtn];
  169. [qCoerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.top.mas_equalTo(yaoqBtn.mas_bottom).mas_offset(10);
  171. make.centerX.mas_equalTo(showBt.mas_centerX);
  172. make.width.mas_equalTo(162);
  173. make.height.mas_equalTo(138);
  174. }];
  175. UIView *btView = [[UIView alloc]init];
  176. btView.backgroundColor=[UIColor whiteColor];
  177. btView.userInteractionEnabled=YES;
  178. [backIMG addSubview:btView];
  179. [btView mas_makeConstraints:^(MASConstraintMaker *make) {
  180. make.bottom.mas_equalTo(-10);
  181. make.left.mas_equalTo(20);
  182. make.right.mas_equalTo(-20);
  183. make.height.mas_equalTo(JX_SCREEN_BOTTOM+15);
  184. }];
  185. NSArray *imageS=@[@"circle_of_friends_icon",@"weixin_logo",@"编组2",@"tabbar22"];
  186. NSArray *titleS=@[@"微信朋友圈",@"微信好友",@"QQ好友",@"保存图片"];
  187. for (int i=0; i<4; i++) {
  188. MyButton *bottomBtn = [[MyButton alloc]init];
  189. //bottomBtn.backgroundColor=kRGBColor246;
  190. bottomBtn.tag=i;
  191. [bottomBtn setTitleColor:kRGBColor(222, 29, 19) forState:UIControlStateNormal];
  192. [bottomBtn setImage:[UIImage imageNamed:imageS[i]] forState:UIControlStateNormal];
  193. [bottomBtn setTitle:titleS[i] forState:UIControlStateNormal];
  194. [bottomBtn addTarget:self action:@selector(saveBttIMG1:) forControlEvents:UIControlEventTouchUpInside];
  195. [btView addSubview:bottomBtn];
  196. [bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  197. make.left.mas_equalTo(i*((JX_SCREEN_WIDTH-40)/4));
  198. make.width.mas_equalTo((JX_SCREEN_WIDTH-40)/4);
  199. make.height.mas_equalTo(btView.mas_height);
  200. }];
  201. }
  202. [SVProgressHUD show];
  203. [g_server getAppResource:@"6" ToView:self];
  204. long time = (long)[[NSDate date] timeIntervalSince1970];
  205. time = (time *1000 + g_server.timeDifference);
  206. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  207. [g_server getact_getinviteget:salt andUserId:g_server.myself.userId andToView:self];
  208. [tableView reloadData];
  209. }
  210. -(CGSize)titleBtnWight:(NSString *)titBtnW and:(UIFont *)titBtn {
  211. CGSize titleSize = [titBtnW boundingRectWithSize:CGSizeMake(JX_SCREEN_WIDTH-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn} context:nil].size;
  212. return titleSize;
  213. }
  214. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  215. NSString *titleStr =_dataArr[indexPath.row];
  216. CGFloat titleH=[self titleBtnWight:titleStr and:[UIFont systemFontOfSize:14 weight:UIFontWeightRegular]].height;
  217. return titleH+6;;
  218. }
  219. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  220. return _dataArr.count;
  221. }
  222. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  223. JXShareMCell *cell = [JXShareMCell cellWithTableView:tableView];
  224. cell.backgroundColor=[UIColor clearColor];
  225. NSString *titleStr =_dataArr[indexPath.row];
  226. cell.strURL=titleStr;
  227. return cell;
  228. }
  229. #pragma mark --- 请求成功
  230. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  231. [SVProgressHUD dismiss];
  232. //NSLog(@"dict: %@ --- arry: %@",dict ,array1 );
  233. if([aDownload.action isEqualToString:act_getAppResource]){
  234. NSDictionary *dict=[array1 firstObject];
  235. NSString *string=dict[@"link"];
  236. //创建过滤器
  237. CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
  238. //过滤器恢复默认
  239. [filter setDefaults];
  240. //给过滤器添加数据<字符串长度893>
  241. NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
  242. [filter setValue:data forKey:@"inputMessage"];
  243. //获取二维码过滤器生成二维码
  244. CIImage *image = [filter outputImage];
  245. UIImage *img = [self createNonInterpolatedUIImageFromCIImage:image WithSize:140];
  246. [self.showBt setImage:img forState:UIControlStateNormal];
  247. }
  248. else if([aDownload.action isEqualToString:act_getinviteget])
  249. {
  250. NSDictionary *dictM=dict;
  251. NSString *str=[NSString stringWithFormat:@"邀请码:%@",dictM[@"invite"]];
  252. [self.yaoqingmaBtn setTitle:str forState:UIControlStateNormal];
  253. }
  254. }
  255. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  256. [SVProgressHUD dismiss];
  257. NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
  258. if([errorCode isEqualToString:@"权限验证失败"])
  259. {
  260. if ([aDownload.action isEqualToString:act_GetBalanceRedTimes])
  261. {
  262. }else{
  263. }
  264. }
  265. return [errorCode intValue];
  266. }
  267. //分享
  268. - (void)saveBttIMG1:(UIButton *)sender{
  269. if (sender.tag==0) {
  270. [self shareAction:
  271. @[UMShareToWechatTimeline] pathUrl:@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862" ];
  272. } if (sender.tag==1) {
  273. [self shareAction:
  274. @[UMShareToWechatSession] pathUrl:@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862" ];
  275. } if (sender.tag==2) {
  276. NSString *musicPath1=@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862";
  277. NSString *yaoqingM =self.yaoqingmaBtn.titleLabel.text;
  278. NSString *dicript = [NSString stringWithFormat:@"您的邀请码是:%@%@",yaoqingM,@" 即信—安全稳定的赚钱平台 \n给你推荐一款可以赚钱的APP。我今天又收入了999元,现在还有3个名额,快进来下载一起赚钱吧!"];
  279. UIImage *shareImage = [UIImage imageNamed:@"ALOGO_120"];
  280. NSURL *url = [NSURL fileURLWithPath:musicPath1];
  281. NSArray * activityItems = @[dicript,shareImage,url];
  282. UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
  283. //去除一些不需要的图标选项
  284. activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook, UIActivityTypeAirDrop, UIActivityTypePostToWeibo, UIActivityTypePostToTencentWeibo];
  285. //成功失败的回调block
  286. UIActivityViewControllerCompletionWithItemsHandler myBlock = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
  287. if (completed){
  288. }else{
  289. }
  290. };
  291. activityVC.completionWithItemsHandler = myBlock;
  292. [self presentViewController:activityVC animated:YES completion:nil];
  293. }
  294. if (sender.tag==3) {
  295. UIImage *saveIMG = [self captureImageFromView:self.view];
  296. UIImageWriteToSavedPhotosAlbum(saveIMG, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
  297. }
  298. }
  299. - (void)saveBttIMG:(UIButton *)showBt{
  300. UIImage *saveIMG = [self captureImageFromView:self.view];
  301. UIImageWriteToSavedPhotosAlbum(saveIMG, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
  302. }
  303. -(UIImage *)captureImageFromView:(UIView *)view{
  304. UIGraphicsBeginImageContextWithOptions(self.view.frame.size,NO, 0);
  305. [[UIColor clearColor] setFill];
  306. [[UIBezierPath bezierPathWithRect:self.view.bounds] fill];
  307. CGContextRef ctx = UIGraphicsGetCurrentContext();
  308. [self.view.layer renderInContext:ctx];
  309. UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  310. UIGraphicsEndImageContext();
  311. return image;
  312. }
  313. //下面得到分享完成的回调
  314. -(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
  315. {
  316. NSLog(@"didFinishGetUMSocialDataInViewController with response is %@",response);
  317. //根据`responseCode`得到发送结果,如果分享成功
  318. if(response.responseCode == UMSResponseCodeSuccess)
  319. {
  320. //得到分享到的微博平台名
  321. NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
  322. }
  323. }
  324. - (void)shareAction:(NSArray *)type pathUrl:(NSString *)musicPath {
  325. //[self shareAction: @[ UMShareToQzone,UMShareToQQ,UMShareToTencent] pathUrl: ];
  326. musicPath=@"https://apps.apple.com/cn/app/%E8%81%8A%E5%95%B5-%E4%B8%8E%E6%9C%8B%E5%8F%8B%E4%B8%80%E8%B5%B7%E7%95%85%E8%81%8A/id1463401862";
  327. NSString *yaoqingM =self.yaoqingmaBtn.titleLabel.text;
  328. NSString *dicript = [NSString stringWithFormat:@"您的邀请码是:%@%@",yaoqingM,@" 即信—安全稳定的赚钱平台 \n给你推荐一款可以赚钱的APP。我今天又收入了999元,现在还有3个名额,快进来下载一起赚钱吧!"];
  329. UIImage *shareImage = [UIImage imageNamed:@"ALOGO_120"];
  330. NSURL *url = [NSURL fileURLWithPath:musicPath];
  331. NSArray * activityItems = @[dicript,musicPath];
  332. UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
  333. //去除一些不需要的图标选项
  334. activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook, UIActivityTypeAirDrop, UIActivityTypePostToWeibo, UIActivityTypePostToTencentWeibo];
  335. //成功失败的回调block
  336. UIActivityViewControllerCompletionWithItemsHandler myBlock = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
  337. if (completed){
  338. }else{
  339. }
  340. };
  341. activityVC.completionWithItemsHandler = myBlock;
  342. [self presentViewController:activityVC animated:YES completion:nil];
  343. return;
  344. NSString *shareText = dicript; //分享内嵌文字
  345. [UMSocialSnsService presentSnsIconSheetView:self appKey:@"5edaacbe978eea085d11d331" shareText:shareText shareImage:shareImage shareToSnsNames:type delegate:self];
  346. return;
  347. }
  348. - (UIImage *)createNonInterpolatedUIImageFromCIImage:(CIImage *)image WithSize:(CGFloat)size
  349. {
  350. CGRect extent = CGRectIntegral(image.extent);
  351. CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent));
  352. //创建bitmap
  353. size_t width = CGRectGetWidth(extent)*scale;
  354. size_t height = CGRectGetHeight(extent)*scale;
  355. CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
  356. CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
  357. CIContext *context = [CIContext contextWithOptions:nil];
  358. CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
  359. CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
  360. CGContextScaleCTM(bitmapRef, scale, scale);
  361. CGContextDrawImage(bitmapRef, extent, bitmapImage);
  362. //保存图片
  363. CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
  364. CGContextRelease(bitmapRef);
  365. CGImageRelease(bitmapImage);
  366. return [UIImage imageWithCGImage:scaledImage];
  367. }
  368. #pragma mark -- <保存到相册>
  369. -(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
  370. NSString *msg = nil ;
  371. if(error){
  372. msg = @"保存图片失败" ;
  373. }else{
  374. msg = @"保存图片成功" ;
  375. }
  376. }
  377. /*
  378. #pragma mark - Navigation
  379. // In a storyboard-based application, you will often want to do a little preparation before navigation
  380. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  381. // Get the new view controller using [segue destinationViewController].
  382. // Pass the selected object to the new view controller.
  383. }
  384. */
  385. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  386. [self.view endEditing:YES];
  387. }
  388. @end