editShareView.m 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // editShareView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/14.
  6. //
  7. #import "editShareView.h"
  8. @interface editShareView ()
  9. @property(nonatomic,strong) UIButton*day7Button;
  10. @property(nonatomic,strong) UIButton*dayForeverButton;
  11. @end
  12. @implementation editShareView
  13. - (id)initWithFrame:(CGRect)frame{
  14. self = [super initWithFrame:frame];
  15. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  16. [self drawAnyView];
  17. return self;
  18. }
  19. - (void)drawAnyView{
  20. UIView *whiteBgView = [[UIView alloc] init];
  21. whiteBgView.backgroundColor = [UIColor whiteColor];
  22. [self addSubview:whiteBgView];
  23. whiteBgView.layer.cornerRadius = 32;
  24. whiteBgView.layer.masksToBounds = YES;
  25. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.left.mas_equalTo(0);
  27. make.right.mas_equalTo(0);
  28. make.bottom.mas_equalTo(0);
  29. make.height.mas_equalTo(315 -50+ AdaptTabHeight);
  30. }];
  31. UILabel *titleLabel = [[UILabel alloc] init];
  32. titleLabel.font = [UIFont systemFontOfSize:18.0];
  33. titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  34. [whiteBgView addSubview:titleLabel];
  35. NSString *leftText = NSLocalizedString(@"share_title_left",nil);
  36. NSString *rightText = NSLocalizedString(@"share_title_right",nil);
  37. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",leftText,rightText];
  38. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  39. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
  40. UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
  41. [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
  42. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  43. titleLabel.attributedText = attrStr;
  44. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(25);
  46. make.right.mas_equalTo(0);
  47. make.top.mas_equalTo(20);
  48. make.height.mas_equalTo(40);
  49. }];
  50. NSString *secondTitleStr = NSLocalizedString(@"share_expiration_date",nil);
  51. UILabel *secondTitleLabel = [[UILabel alloc] init];
  52. secondTitleLabel.font = [UIFont systemFontOfSize:14.0];
  53. secondTitleLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
  54. secondTitleLabel.text = secondTitleStr;
  55. [whiteBgView addSubview:secondTitleLabel];
  56. CGFloat secondWith = [secondTitleStr boundingRectWithSize:CGSizeMake(300, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width;
  57. [secondTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.mas_equalTo(25);
  59. make.width.mas_equalTo(secondWith);
  60. make.top.equalTo(titleLabel.mas_bottom).offset(10);
  61. make.height.mas_equalTo(25);
  62. }];
  63. _day7Button = [[UIButton alloc] init];
  64. [_day7Button setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
  65. [_day7Button setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
  66. [_day7Button setTitle:NSLocalizedString(@"share_expiration_date_7",nil) forState:UIControlStateNormal];
  67. [_day7Button setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  68. [_day7Button addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  69. _day7Button.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  70. _day7Button.tag = 1;
  71. [whiteBgView addSubview:_day7Button];
  72. _day7Button.selected = YES;
  73. [_day7Button mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.equalTo(secondTitleLabel.mas_right).offset(5);
  75. make.width.mas_equalTo(100);
  76. make.top.equalTo(secondTitleLabel.mas_top).offset(0);
  77. make.height.mas_equalTo(25);
  78. }];
  79. _dayForeverButton = [[UIButton alloc] init];
  80. [_dayForeverButton setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
  81. [_dayForeverButton setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
  82. [_dayForeverButton setTitle:NSLocalizedString(@"share_expiration_date_forever",nil) forState:UIControlStateNormal];
  83. [_dayForeverButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  84. [_dayForeverButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  85. _dayForeverButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  86. _dayForeverButton.tag = 2;
  87. [whiteBgView addSubview:_dayForeverButton];
  88. [_dayForeverButton mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.equalTo(_day7Button.mas_right).offset(15);
  90. make.width.mas_equalTo(100);
  91. make.top.equalTo(secondTitleLabel.mas_top).offset(0);
  92. make.height.mas_equalTo(25);
  93. }];
  94. NSArray *titleArr = @[NSLocalizedString(@"share_by_weixin",nil),
  95. NSLocalizedString(@"share_by_QQ",nil),
  96. NSLocalizedString(@"share_by_timeLine",nil),
  97. NSLocalizedString(@"share_by_secret",nil)];
  98. NSArray *imageStrArr = @[@"share_weixin_icon",
  99. @"share_qq_icon",
  100. @"share_weixin_Timeline_icon",
  101. @"share_secret_icon"];
  102. CGFloat curButFullWidth = SCREEN_W/4.0;
  103. for (int i = 0; i< titleArr.count; i++) {
  104. UIButton*curButton = [[UIButton alloc] init];
  105. [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  106. curButton.tag = 10+i;
  107. [whiteBgView addSubview:curButton];
  108. [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.width.mas_equalTo(curButFullWidth);
  110. make.left.mas_equalTo(i*curButFullWidth);
  111. make.height.mas_equalTo(80);
  112. make.top.equalTo(secondTitleLabel.mas_bottom).offset(20);
  113. }];
  114. UIView *imageBgView = [[UIView alloc] init];
  115. imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
  116. imageBgView.layer.cornerRadius = 8;
  117. imageBgView.layer.masksToBounds = YES;
  118. [curButton addSubview:imageBgView];
  119. [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.width.mas_equalTo(64);
  121. make.height.mas_equalTo(52);
  122. make.centerX.equalTo(curButton.mas_centerX);
  123. make.top.mas_equalTo(0);
  124. }];
  125. UIImageView *leftImageV = [[UIImageView alloc] init];
  126. leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
  127. [imageBgView addSubview:leftImageV];
  128. [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.width.mas_equalTo(25);
  130. make.height.mas_equalTo(25);
  131. make.centerX.equalTo(imageBgView.mas_centerX);
  132. make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
  133. }];
  134. UILabel *leftLabel = [[UILabel alloc] init];
  135. leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
  136. leftLabel.textAlignment = NSTextAlignmentCenter;
  137. leftLabel.font = [UIFont systemFontOfSize:12.0];
  138. leftLabel.text = titleArr[i];
  139. [curButton addSubview:leftLabel];
  140. [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.width.mas_equalTo(curButFullWidth);
  142. make.height.mas_equalTo(25);
  143. make.centerX.equalTo(curButton.mas_centerX);
  144. make.top.equalTo(imageBgView.mas_bottom).offset(10);
  145. }];
  146. }
  147. UIButton*cancelButton = [[UIButton alloc] init];
  148. [cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  149. [cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  150. [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  151. cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  152. cancelButton.tag = 100;
  153. [whiteBgView addSubview:cancelButton];
  154. [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.left.mas_equalTo(0);
  156. make.right.mas_equalTo(0);
  157. make.bottom.mas_equalTo(-AdaptTabHeight);
  158. make.height.mas_equalTo(40);
  159. }];
  160. UIView *lineView = [[UIView alloc] init];
  161. lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
  162. [whiteBgView addSubview:lineView];
  163. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.left.mas_equalTo(25);
  165. make.right.mas_equalTo(-25);
  166. make.bottom.equalTo(cancelButton.mas_top).offset(-5);
  167. make.height.mas_equalTo(1);
  168. }];
  169. }
  170. - (void)didClickButFun:(UIButton*)but
  171. {
  172. NSInteger tag = but.tag;
  173. if(tag==1 && !_day7Button.selected){
  174. _day7Button.selected = YES;
  175. _dayForeverButton.selected = NO;
  176. }
  177. else if(tag==2 && !_dayForeverButton.selected){
  178. _day7Button.selected = NO;
  179. _dayForeverButton.selected = YES;
  180. }
  181. else if(tag == 100){
  182. [self removeFromSuperview];
  183. }
  184. // if(_didClickButtonFun){
  185. // _didClickButtonFun(tag);
  186. // }
  187. }
  188. @end