BGShareView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // BGShareView.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 2017/3/23.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGShareView.h"
  9. @implementation BGShareView
  10. -(id)initWithFrame:(CGRect)frame Delegate:(id<shareDeleGate>)delegate
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self)
  14. {
  15. self.SDeleGate = delegate;
  16. self.shareArray = [NSMutableArray new];
  17. self.backgroundColor = kBackGroundColor;
  18. self.BuguLive = [GlobalVariables sharedInstance];
  19. [self creatMainView];
  20. }
  21. return self;
  22. }
  23. - (void)creatMainView
  24. {
  25. [self getShareArr];
  26. _buttomView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, self.frame.size.height)];
  27. _buttomView.backgroundColor = kWhiteColor;
  28. [self addSubview:_buttomView];
  29. _shareLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 60, self.frame.size.height)];
  30. _shareLabel.text = ASLocalizedString(@"分享至:");
  31. _shareLabel.textColor = RGB(153, 153, 153);
  32. _shareLabel.font = [UIFont systemFontOfSize:14];
  33. [_buttomView addSubview:_shareLabel];
  34. for (int i = 0; i < _shareArray.count; i ++)
  35. {
  36. UIImageView *shareImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-10-42-(10+42)*i, 9, 42, 42)];
  37. shareImgView.userInteractionEnabled = YES;
  38. shareImgView.tag = [_shareArray[i] intValue];
  39. if ([_shareArray[i] intValue] == 0)
  40. {
  41. shareImgView .image = [UIImage imageNamed:@"fw_share_weiBo"];
  42. }else if ([_shareArray[i] intValue] == 1)
  43. {
  44. shareImgView .image = [UIImage imageNamed:@"fw_share_circle"];
  45. }else if ([_shareArray[i] intValue] == 2)
  46. {
  47. shareImgView .image = [UIImage imageNamed:@"fw_share_wechat"];
  48. }else if ([_shareArray[i] intValue] == 3)
  49. {
  50. shareImgView .image = [UIImage imageNamed:@"fw_share_qq"];
  51. }else if ([_shareArray[i] intValue] == 4)
  52. {
  53. shareImgView .image = [UIImage imageNamed:@"fw_share_qqCircle"];
  54. }
  55. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(shareImgTap:)];
  56. [shareImgView addGestureRecognizer:tap];
  57. [_buttomView addSubview:shareImgView];
  58. }
  59. }
  60. //0新浪 1朋友圈 2微信 3qq 4qq空间
  61. - (void)getShareArr
  62. {
  63. if (_BuguLive.appModel.qq_app_api == 1)//qq空间
  64. {
  65. [_shareArray addObject:@"4"];
  66. }
  67. if (_BuguLive.appModel.sina_app_api == 1)//新浪
  68. {
  69. [_shareArray addObject:@"0"];
  70. }
  71. if (_BuguLive.appModel.wx_app_api == 1)//朋友圈
  72. {
  73. [_shareArray addObject:@"1"];
  74. }
  75. if (_BuguLive.appModel.wx_app_api == 1)//微信
  76. {
  77. [_shareArray addObject:@"2"];
  78. }
  79. if (_BuguLive.appModel.qq_app_api == 1)//qq
  80. {
  81. [_shareArray addObject:@"3"];
  82. }
  83. }
  84. #pragma mark 图片的点击事件
  85. - (void)shareImgTap:(UITapGestureRecognizer *)tap
  86. {
  87. if (self.SDeleGate && [self.SDeleGate respondsToSelector:@selector(clickShareImgViewWithTag:)])
  88. {
  89. [self.SDeleGate clickShareImgViewWithTag:(int)tap.view.tag];
  90. }
  91. }
  92. @end