线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQShareGetFriendsView.m 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //
  2. // HSQShareGetFriendsView.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/5/24.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. //#define QRwidth (120)
  9. #import "HSQShareGetFriendsView.h"
  10. @interface HSQShareGetFriendsView()
  11. {
  12. NSInteger count;
  13. }
  14. @property(nonatomic,strong)UIImageView *centerImageView;
  15. @property(nonatomic,strong)UIImageView *yhIconImageView;
  16. @property(nonatomic,strong)UILabel *yhTitleLabel;
  17. @property(nonatomic,strong)UILabel *getFirendCodeLabel;
  18. @property(nonatomic,strong)UIImageView *QRcodeImageView;
  19. @property(nonatomic,strong)UILabel *bottomLabel;
  20. @property(nonatomic,strong)UIImageView *userIcon;
  21. @property(nonatomic,strong)UILabel *nickName;
  22. @property(nonatomic,strong)UILabel *inviteCode;
  23. @end
  24. @implementation HSQShareGetFriendsView
  25. static NSInteger QRwidth;
  26. -(instancetype)initWithFrame:(CGRect)frame{
  27. if (self=[super initWithFrame:frame]) {
  28. if (iPhone6) {
  29. QRwidth=100;
  30. }else if(iPhone5){
  31. QRwidth=80;
  32. }else{
  33. QRwidth=120;
  34. }
  35. }
  36. return self;
  37. }
  38. -(void)setModel:(HSQShareGetFriendsModel *)model{
  39. _model=model;
  40. [self addUI];
  41. [self otherOP];
  42. }
  43. -(void)addUI{
  44. [self addSubview:self.centerImageView];
  45. [self addSubview:self.yhIconImageView];
  46. [self addSubview:self.yhTitleLabel];
  47. // [self addSubview:self.getFirendCodeLabel];
  48. [self addSubview:self.QRcodeImageView];
  49. [self addSubview:self.bottomLabel];
  50. [self addSubview:self.inviteCode];
  51. [self addSubview:self.userIcon];
  52. [self addSubview:self.nickName];
  53. }
  54. - (void)setUserinfo:(NSDictionary *)userinfo {
  55. _userinfo = userinfo;
  56. self.inviteCode.text = [NSString stringWithFormat:@"邀请码:%@",userinfo[@"invite_code"]];
  57. [self.userIcon sd_setImageWithURL:[NSURL URLWithString:userinfo[@"headimg"]] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  58. count++;
  59. if (count > 1) {
  60. if (self.imgSuccBlock) {
  61. self.imgSuccBlock();
  62. }
  63. }
  64. }];
  65. self.nickName.text = userinfo[@"nickname"];
  66. }
  67. -(void)otherOP{
  68. if (self.model.imgUrl) {//url存在
  69. [self.centerImageView sd_setImageWithURL:[NSURL URLWithString:self.model.imgUrl] placeholderImage:[UIImage imageNamed:@""] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  70. if (self.model.headimg.length > 0) {
  71. [self.userIcon sd_setImageWithURL:[NSURL URLWithString:self.model.headimg] placeholderImage:[UIImage imageNamed:@"lgoin"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  72. if (self.imgSuccBlock) {
  73. self.imgSuccBlock();
  74. }
  75. }];
  76. }else {
  77. count++;
  78. if (count > 1) {
  79. if (self.imgSuccBlock) {
  80. self.imgSuccBlock();
  81. }
  82. }
  83. }
  84. }];
  85. }else if(self.model.img) {//img存在
  86. [self.centerImageView setImage:self.model.img];
  87. [self.userIcon sd_setImageWithURL:[NSURL URLWithString:self.model.headimg] placeholderImage:[UIImage imageNamed:@"lgoin"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  88. if (self.imgSuccBlock) {
  89. self.imgSuccBlock();
  90. }
  91. }];
  92. }else{
  93. if (self.imgSuccBlock) {
  94. self.imgSuccBlock();
  95. }
  96. }
  97. }
  98. -(UIImageView *)centerImageView{
  99. if (!_centerImageView) {// (self.width-FITSIZE(44))*(425.0f/330.0f)
  100. CGFloat width = self.width-FITSIZE(64);
  101. _centerImageView=[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(22), FITHeightSIZE(20),width, width*1.38)];
  102. _centerImageView.contentMode=UIViewContentModeScaleAspectFit;
  103. _centerImageView.backgroundColor=[UIColor clearColor];
  104. }
  105. return _centerImageView;
  106. }
  107. - (UIImageView *)yhIconImageView{
  108. if (!_yhIconImageView) {
  109. _yhIconImageView=[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(30), self.inviteCode.bottom+FITHeightSIZE(15), 22, 22)];
  110. [_yhIconImageView setImage:[UIImage imageNamed:@"share_appicon"]];
  111. }
  112. return _yhIconImageView;
  113. }
  114. - (UILabel *)yhTitleLabel{
  115. if (!_yhTitleLabel) {
  116. _yhTitleLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.yhIconImageView.right+FITSIZE(11), 0, 0, 0)];
  117. _yhTitleLabel.textColor=[UIColor YHColorWithHex:0x333333];
  118. _yhTitleLabel.font=[UIFont systemFontOfSize:14];
  119. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  120. NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  121. _yhTitleLabel.text=app_Name;
  122. [_yhTitleLabel sizeToFit];
  123. _yhTitleLabel.centerY=self.yhIconImageView.centerY;
  124. }
  125. return _yhTitleLabel;
  126. }
  127. - (UILabel *)getFirendCodeLabel{
  128. if (!_getFirendCodeLabel) {
  129. _getFirendCodeLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.yhTitleLabel.right+20, self.yhIconImageView.bottom+15, 0, 0)];
  130. _getFirendCodeLabel.font=[UIFont systemFontOfSize:14];
  131. _getFirendCodeLabel.textColor=[UIColor YHColorWithHex:0x262626];
  132. _getFirendCodeLabel.text=[NSString stringWithFormat:@"选的对 赚得多"];
  133. [_getFirendCodeLabel sizeToFit];
  134. _getFirendCodeLabel.centerY = self.yhIconImageView.centerY;
  135. }
  136. return _getFirendCodeLabel;
  137. }
  138. - (UIImageView *)QRcodeImageView{
  139. if (!_QRcodeImageView) {
  140. _QRcodeImageView=[[UIImageView alloc]initWithFrame:CGRectMake(self.width-FITSIZE((30+QRwidth)), self.centerImageView.bottom+28, FITSIZE(QRwidth), FITSIZE(QRwidth))];
  141. //1. 实例化二维码滤镜
  142. CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
  143. // 2. 恢复滤镜的默认属性
  144. [filter setDefaults];
  145. // 3. 将字符串转换成NSData
  146. NSString *urlStr =@"http://www.ourname.xin";
  147. if (self.model.QRcodeUrl) {
  148. urlStr=self.model.QRcodeUrl;
  149. }
  150. NSData *data = [urlStr dataUsingEncoding:NSUTF8StringEncoding];
  151. // 4. 通过KVO设置滤镜inputMessage数据
  152. [filter setValue:data forKey:@"inputMessage"];
  153. // 5. 获得滤镜输出的图像
  154. CIImage *outputImage = [filter outputImage];
  155. UIImage *img=[outputImage createNonInterpolatedUIImagewithSize:FITSIZE(QRwidth)];
  156. [_QRcodeImageView setImage:img];
  157. _QRcodeImageView.backgroundColor=[UIColor yhGrayColor];
  158. }
  159. return _QRcodeImageView;
  160. }
  161. - (UILabel *)bottomLabel{
  162. if (!_bottomLabel) {
  163. _bottomLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, self.height-37, self.width, 37)];
  164. _bottomLabel.text=@"1.微信扫码下载 →2.微信登录 →3.开启优选之旅";
  165. [_bottomLabel adjustsFontSizeToFitWidth];
  166. _bottomLabel.textAlignment=NSTextAlignmentCenter;
  167. _bottomLabel.backgroundColor=[UIColor YHColorWithHex:0xF2F2F2];
  168. _bottomLabel.textColor=[UIColor YHColorWithHex:0x666666];
  169. _bottomLabel.font=[UIFont systemFontOfSize:14];
  170. }
  171. return _bottomLabel;
  172. }
  173. - (UIImageView *)userIcon {
  174. if (!_userIcon) {
  175. _userIcon = [[UIImageView alloc] initWithFrame:CGRectMake(Fitsize(30), self.centerImageView.bottom+28, FITHeightSIZE(30), FITHeightSIZE(30))];
  176. _userIcon.layer.cornerRadius = FITHeightSIZE(15);
  177. _userIcon.backgroundColor = [UIColor yhGrayColor];
  178. _userIcon.layer.masksToBounds = YES;
  179. }
  180. return _userIcon;
  181. }
  182. - (UILabel *)nickName {
  183. if (!_nickName) {
  184. _nickName = [[UILabel alloc] initWithFrame:CGRectMake(self.userIcon.right+5, 0, Fitsize(180), 20)];
  185. _nickName.textColor = [UIColor YHColorWithHex:0x333333];
  186. _nickName.font = [UIFont systemFontOfSize:Fitsize(14)];
  187. _nickName.centerY = self.userIcon.centerY;
  188. _nickName.text = self.model.nickname;
  189. }
  190. return _nickName;
  191. }
  192. - (UILabel *)inviteCode {
  193. if (!_inviteCode) {
  194. _inviteCode = [[UILabel alloc] initWithFrame:CGRectMake(Fitsize(30), self.userIcon.bottom+FITHeightSIZE(15), FITHeightSIZE(180), 20)];
  195. _inviteCode.textColor = [UIColor YHColorWithHex:0x333333];
  196. _inviteCode.font = [UIFont systemFontOfSize:Fitsize(14)];
  197. _inviteCode.text = [NSString stringWithFormat:@"邀请码:%@",self.model.inviteCode];
  198. }
  199. return _inviteCode;
  200. }
  201. @end