SSaveHeadViewVC.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // SSaveHeadViewVC.m
  3. // BuguLive
  4. //
  5. // Created by 丁凯 on 2017/7/18.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SSaveHeadViewVC.h"
  9. @interface SSaveHeadViewVC ()
  10. @end
  11. @implementation SSaveHeadViewVC
  12. - (void)viewDidLoad
  13. {
  14. [super viewDidLoad];
  15. }
  16. - (void)initFWUI
  17. {
  18. [super initFWUI];
  19. self.view.backgroundColor = kWhiteColor;
  20. self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, kStatusBarHeight, kScreenW, kScreenW)];
  21. self.imgView.userInteractionEnabled = YES;
  22. [self.imgView sd_setImageWithURL:self.url placeholderImage:kDefaultPreloadHeadImg];
  23. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
  24. self.imgView.contentMode = UIViewContentModeScaleAspectFit;
  25. [self.imgView addGestureRecognizer:tap];
  26. [self.view addSubview:self.imgView];
  27. UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  28. backBtn.frame = CGRectMake(10, 10, 50, 50);
  29. [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
  30. backBtn.layer.cornerRadius = 25;
  31. backBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
  32. backBtn.tag = 101;
  33. [backBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  34. [self.imgView addSubview:backBtn];
  35. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  36. button.frame = CGRectMake(kScreenW*0.1, kScreenH-100, kScreenW*0.8, 40);
  37. button.backgroundColor = kAppMainColor;
  38. button.tag = 100;
  39. button.layer.cornerRadius = 18;
  40. [button setTitle:ASLocalizedString(@"保存到相册")forState:0];
  41. [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  42. [button setTitleColor:[UIColor whiteColor] forState:0];
  43. [self.view addSubview:button];
  44. UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
  45. deleteButton.frame = CGRectMake(kScreenW*0.1,kScreenH-50,kScreenW*0.8, 40);
  46. deleteButton.tag = 101;
  47. deleteButton.titleLabel.font = [UIFont systemFontOfSize:22];
  48. [deleteButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  49. [deleteButton setTitle:@"X" forState:0];
  50. [deleteButton setTitleColor:kAppMainColor forState:0];
  51. [self.view addSubview:deleteButton];
  52. }
  53. - (void)viewWillAppear:(BOOL)animated
  54. {
  55. [super viewWillAppear:animated];
  56. [self.navigationController setNavigationBarHidden:YES];
  57. }
  58. - (void)viewWillDisappear:(BOOL)animated
  59. {
  60. [super viewWillDisappear:animated];
  61. self.navigationController.navigationBar.tintColor = kClearColor;
  62. [self.navigationController setNavigationBarHidden:NO];
  63. }
  64. - (void)buttonClick:(UIButton *)button
  65. {
  66. int index = (int)button.tag-100;
  67. if (index == 0)
  68. {
  69. UIImageWriteToSavedPhotosAlbum(self.imgView.image, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
  70. }else if (index == 1)
  71. {
  72. [[AppDelegate sharedAppDelegate]popViewController];
  73. }
  74. }
  75. - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
  76. {
  77. if (!error)
  78. {
  79. [FanweMessage alert:ASLocalizedString(@"保存成功")];
  80. }else
  81. {
  82. [FanweMessage alert:ASLocalizedString(@"保存失败")];
  83. }
  84. }
  85. - (void)tap
  86. {
  87. [[AppDelegate sharedAppDelegate]popViewController];
  88. }
  89. @end