ThirdSharedView.m 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //
  2. // ThirdSharedView.m
  3. // TheoryNetwork
  4. //
  5. // Created by tederen on 2019/10/10.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "ThirdSharedView.h"
  9. @interface ThirdSharedView ()
  10. @property (nonatomic, strong) UIView *bgView;
  11. @end
  12. @implementation ThirdSharedView
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. UIView *alphaback = [[UIView alloc]init];
  18. [self addSubview:alphaback];
  19. alphaback.backgroundColor = UIColorHex(000000);
  20. alphaback.alpha = 0.5;
  21. alphaback.frame = self.bounds;
  22. [self addSubview:self.bgView];
  23. [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
  24. make.width.equalTo(self);
  25. make.height.mas_equalTo(300);
  26. if (@available(iOS 11.0, *)) {
  27. make.bottom.equalTo(self.mas_safeAreaLayoutGuideBottom);
  28. } else {
  29. make.bottom.equalTo(self.mas_bottom);
  30. }
  31. }];
  32. [self.bgView addSubview:self.wechatButton];
  33. [self.bgView addSubview:self.friendButton];
  34. [self.bgView addSubview:self.weiboButton];
  35. [self.bgView addSubview:self.tencentButton];
  36. UIView *lineView = [[UIView alloc]init];
  37. [self.bgView addSubview:lineView];
  38. [self.bgView addSubview:self.sendInfoButton];
  39. [self.bgView addSubview:self.sendGroupButton];
  40. [self.bgView addSubview:self.sendNoteButton];
  41. [self.bgView addSubview:self.sendTopicButton];
  42. [self.bgView addSubview:self.cancelButton];
  43. CGFloat topMaigin = 8;
  44. _wechatButton.frame = CGRectMake(0, topMaigin, kGXScreenWidth/4.0, 100);
  45. _friendButton.frame = CGRectMake(kGXScreenWidth/4.0, topMaigin, kGXScreenWidth/4.0, 100);
  46. _weiboButton.frame = CGRectMake(kGXScreenWidth/2.0, topMaigin, kGXScreenWidth/4.0, 100);
  47. _tencentButton.frame = CGRectMake(kGXScreenWidth/4.0 * 3, topMaigin, kGXScreenWidth/4.0, 100);
  48. topMaigin += 100;
  49. topMaigin += 10.f;
  50. lineView.backgroundColor = UIColorHex(CCCCCC);
  51. lineView.frame = CGRectMake(0, topMaigin,kGXScreenWidth,0.5);
  52. topMaigin+= 10.f;
  53. _sendInfoButton.frame = CGRectMake(0,topMaigin, kGXScreenWidth/4.0, 100);
  54. _sendGroupButton.frame = CGRectMake(kGXScreenWidth/4.0,topMaigin, kGXScreenWidth/4.0, 100);
  55. _sendNoteButton.frame = CGRectMake(kGXScreenWidth/2.0,topMaigin, kGXScreenWidth/4.0, 100);
  56. _sendTopicButton .frame = CGRectMake(kGXScreenWidth/4.0 * 3,topMaigin, kGXScreenWidth/4.0, 100);
  57. topMaigin += 150;
  58. [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.bottom.equalTo(self.bgView);
  60. make.left.equalTo(self.bgView);
  61. make.right.equalTo(self.bgView);
  62. make.height.mas_equalTo(45);
  63. }];
  64. [_wechatButton verticalImageAndTitle:20.f];
  65. [_friendButton verticalImageAndTitle:20.f];
  66. [_weiboButton verticalImageAndTitle:20.f];
  67. [_tencentButton verticalImageAndTitle:20.f];
  68. [_sendInfoButton verticalImageAndTitle:20.f];
  69. [_sendGroupButton verticalImageAndTitle:20.f];
  70. [_sendNoteButton verticalImageAndTitle:20.f];
  71. [_sendTopicButton verticalImageAndTitle:20.f];
  72. [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
  73. make.width.equalTo(self);
  74. make.height.mas_equalTo(300);
  75. if (@available(iOS 11.0, *)) {
  76. make.bottom.equalTo(self.mas_safeAreaLayoutGuideBottom);
  77. } else {
  78. make.bottom.equalTo(self.mas_bottom);
  79. }
  80. }];
  81. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeFromSuperview)];
  82. [self addGestureRecognizer:tap];
  83. }
  84. return self;
  85. }
  86. - (void)enterButtonAction:(TDButton *)sender {
  87. [self removeFromSuperview];
  88. if (self.clickShareBlock) {
  89. self.clickShareBlock(sender);
  90. }
  91. }
  92. #pragma mark - setter
  93. - (UIView *)bgView {
  94. if (!_bgView) {
  95. _bgView = [UIView new];
  96. _bgView.frame = CGRectMake(0, kGXScreenHeigh-kTabBarHeight-300, kGXScreenWidth, 300);
  97. _bgView.backgroundColor = UIColorHex(F5F5F5);
  98. }
  99. return _bgView;
  100. }
  101. - (TDButton *)wechatButton {
  102. if (!_wechatButton) {
  103. _wechatButton = [[TDButton alloc] init];
  104. [_wechatButton setTitle:@"发给微信好友" forState:UIControlStateNormal];
  105. [_wechatButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  106. [[_wechatButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  107. [_wechatButton setImage:IMG(@"icon_share_wechat") forState:UIControlStateNormal];
  108. [_wechatButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  109. _wechatButton.tag = 1001;
  110. }
  111. return _wechatButton;
  112. }
  113. - (TDButton *)friendButton {
  114. if (!_friendButton) {
  115. _friendButton = [[TDButton alloc] init];
  116. [_friendButton setTitle:@"发到朋友圈" forState:UIControlStateNormal];
  117. [_friendButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  118. [[_friendButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  119. [_friendButton setImage:IMG(@"icon_share_friend") forState:UIControlStateNormal];
  120. [_friendButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  121. _friendButton.tag = 1002;
  122. }
  123. return _friendButton;
  124. }
  125. - (TDButton *)weiboButton {
  126. if (!_weiboButton) {
  127. _weiboButton = [[TDButton alloc] init];
  128. [_weiboButton setTitle:@"发到微博" forState:UIControlStateNormal];
  129. [_weiboButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  130. [[_weiboButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  131. [_weiboButton setImage:IMG(@"icon_share_weibo") forState:UIControlStateNormal];
  132. [_weiboButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  133. _weiboButton.tag = 1003;
  134. }
  135. return _weiboButton;
  136. }
  137. - (TDButton *)tencentButton {
  138. if (!_tencentButton) {
  139. _tencentButton = [[TDButton alloc] init];
  140. [_tencentButton setTitle:@"发给QQ好友" forState:UIControlStateNormal];
  141. [_tencentButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  142. [[_tencentButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  143. [_tencentButton setImage:IMG(@"icon_share_tencent") forState:UIControlStateNormal];
  144. [_tencentButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  145. _tencentButton.tag = 1003;
  146. }
  147. return _tencentButton;
  148. }
  149. - (TDButton *)sendInfoButton{
  150. if (!_sendInfoButton) {
  151. _sendInfoButton = [[TDButton alloc] init];
  152. [_sendInfoButton setTitle:@"发送消息" forState:UIControlStateNormal];
  153. [_sendInfoButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  154. [[_sendInfoButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  155. [_sendInfoButton setImage:IMG(@"icon_share_info") forState:UIControlStateNormal];
  156. [_sendInfoButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  157. _sendInfoButton.tag = 2001;
  158. }
  159. return _sendInfoButton;
  160. }
  161. - (TDButton *)sendGroupButton{
  162. if (!_sendGroupButton) {
  163. _sendGroupButton = [[TDButton alloc] init];
  164. [_sendGroupButton setTitle:@"发送小组" forState:UIControlStateNormal];
  165. [_sendGroupButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  166. [[_sendGroupButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  167. [_sendGroupButton setImage:IMG(@"icon_share_xiaozu") forState:UIControlStateNormal];
  168. [_sendGroupButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  169. _sendGroupButton.tag = 2002;
  170. }
  171. return _sendGroupButton;
  172. }
  173. - (TDButton *)sendNoteButton{
  174. if (!_sendNoteButton) {
  175. _sendNoteButton = [[TDButton alloc]init];
  176. [_sendNoteButton setTitle:@"发送笔记" forState:UIControlStateNormal];
  177. [_sendNoteButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  178. [[_sendNoteButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  179. [_sendNoteButton setImage:IMG(@"icon_share_note") forState:UIControlStateNormal];
  180. [_sendNoteButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  181. _sendNoteButton.tag = 2003;
  182. }
  183. return _sendNoteButton;
  184. }
  185. - (TDButton *)sendTopicButton{
  186. if (!_sendTopicButton) {
  187. _sendTopicButton = [[TDButton alloc]init];
  188. [_sendTopicButton setTitle:@"发送话题" forState:UIControlStateNormal];
  189. [_sendTopicButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  190. [[_sendTopicButton titleLabel] setFont:[UIFont systemFontOfSize:12.f]];
  191. [_sendTopicButton setImage:IMG(@"icon_share_topic") forState:UIControlStateNormal];
  192. [_sendTopicButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchDown];
  193. _sendTopicButton.tag = 2004;
  194. }
  195. return _sendTopicButton;
  196. }
  197. - (TDButton *)cancelButton {
  198. if (!_cancelButton) {
  199. _cancelButton = [[TDButton alloc] init];
  200. [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
  201. [_cancelButton setTitleColor:UIColorHex(666666) forState:UIControlStateNormal];
  202. [[_cancelButton titleLabel] setFont:[UIFont systemFontOfSize:18.f]];
  203. _cancelButton.backgroundColor = [UIColor whiteColor];
  204. [_cancelButton addTarget:self action:@selector(removeFromSuperview) forControlEvents:UIControlEventTouchUpInside];
  205. }
  206. return _cancelButton;
  207. }
  208. @end