《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRBottomShareView.m 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // DRBottomShareView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2019/1/2.
  6. // Copyright © 2019年 kuxuan. All rights reserved.
  7. //
  8. #import "DRBottomShareView.h"
  9. #import <WXApi.h>
  10. @implementation DRBottomShareView
  11. - (instancetype)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. [self initSubViews];
  16. }
  17. return self;
  18. }
  19. - (void)initSubViews {
  20. NSArray *titles = @[@"分享朋友圈",@"分享给好友",@"复制淘口令",@"批量存图"];
  21. NSArray *icons = @[@"wx_section",@"wx_wechat",@"copy_code",@"save_img"];
  22. CGFloat width = (self.width)/4;
  23. CGFloat height = width;
  24. for (int i = 0; i < titles.count; i++) {
  25. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i*width, 0, width, height)];
  26. [button setTitle:titles[i] forState:UIControlStateNormal];
  27. button.titleLabel.font = [UIFont systemFontOfSize:13];
  28. [button setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  29. [button setImage:[UIImage imageNamed:icons[i]] forState:UIControlStateNormal];
  30. [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:10];
  31. button.tag = 1000+i;
  32. [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  33. [self addSubview:button];
  34. if (i<2 && ![WXApi isWXAppInstalled]) {
  35. button.hidden = YES;
  36. }
  37. }
  38. }
  39. - (void)buttonAction:(UIButton *)sender {
  40. NSInteger index = sender.tag - 1000;
  41. if (self.delegate && [self.delegate respondsToSelector:@selector(BottomShareViewDidSelectedIndex:)]) {
  42. [self.delegate BottomShareViewDidSelectedIndex:index];
  43. }
  44. }
  45. @end