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

DRTimeLineShareView.m 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // DRTimeLineShareView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2019/1/7.
  6. // Copyright © 2019年 kuxuan. All rights reserved.
  7. //
  8. #import "DRTimeLineShareView.h"
  9. @interface DRTimeLineShareView ()
  10. {
  11. UIView *_alphaView;
  12. UIView *_bgView;
  13. }
  14. @end
  15. @implementation DRTimeLineShareView
  16. - (instancetype)initWithFrame:(CGRect)frame
  17. {
  18. self = [super initWithFrame:frame];
  19. if (self) {
  20. self.userInteractionEnabled = YES;
  21. self.backgroundColor = [UIColor clearColor];
  22. self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
  23. _alphaView = [[UIView alloc] initWithFrame:self.bounds];
  24. _alphaView.backgroundColor = [UIColor blackColor];
  25. _alphaView.alpha = 0.0;
  26. [self addSubview:_alphaView];
  27. [self sendSubviewToBack:_alphaView];
  28. [_alphaView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];
  29. [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];
  30. self.autoresizesSubviews = YES ;
  31. _alphaView.autoresizesSubviews = YES ;
  32. //取消
  33. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tappedCancel)];
  34. [_alphaView addGestureRecognizer:tapGesture];
  35. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.height, self.width, 174)];
  36. _bgView = bgView;
  37. bgView.backgroundColor = [UIColor whiteColor];
  38. [self addSubview:bgView];
  39. NSArray *titles = @[@"分享朋友圈",@"分享给好友",@"保存图片"];
  40. NSArray *icons = @[@"wx_section",@"wx_wechat",@"save_img"];
  41. CGFloat width = SCREEN_WIDTH/3;
  42. for (int i = 0; i < titles.count; i++) {
  43. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(width*i, 0, width, 125)];
  44. [button setTitle:titles[i] forState:UIControlStateNormal];
  45. button.titleLabel.font = [UIFont systemFontOfSize:13];
  46. [button setImage:[UIImage imageNamed:icons[i]] forState:UIControlStateNormal];
  47. [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:10];
  48. [bgView addSubview:button];
  49. [button setTitleColor:[UIColor YHColorWithHex:0x414141] forState:UIControlStateNormal];
  50. button.tag = 1000+i;
  51. [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  52. }
  53. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 125, self.width, 1)];
  54. line.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
  55. [bgView addSubview:line];
  56. UIButton *cancel = [[UIButton alloc] initWithFrame:CGRectMake(0, 125, self.width, 48)];
  57. [cancel setTitle:@"取消" forState:UIControlStateNormal];
  58. [cancel addTarget:self action:@selector(tappedCancel) forControlEvents:UIControlEventTouchUpInside];
  59. cancel.titleLabel.font = [UIFont systemFontOfSize:15];
  60. [cancel setTitleColor:[UIColor YHColorWithHex:0x9B9B9B] forState:UIControlStateNormal];
  61. [bgView addSubview:cancel];
  62. }
  63. return self;
  64. }
  65. - (void)buttonClick:(UIButton *)sender {
  66. NSInteger index = sender.tag - 1000;
  67. if (self.delegate && [self.delegate respondsToSelector:@selector(timelineShareViewDidSeledtedIndex:model:indexPath:)]) {
  68. [self.delegate timelineShareViewDidSeledtedIndex:index model:self.model indexPath:self.indexPath];
  69. }
  70. }
  71. -(void)showInView:(UIView *)view
  72. {
  73. [view addSubview:self];
  74. [UIView animateWithDuration:0.25
  75. animations:^{
  76. _alphaView.alpha = 0.5;
  77. [_bgView setFrame:CGRectMake(0, self.height-_bgView.height, self.width, _bgView.height)];
  78. }];
  79. }
  80. -(void)tappedCancel
  81. {
  82. [UIView animateWithDuration:0.25
  83. animations:^{
  84. _alphaView.alpha = 0;
  85. [_bgView setFrame:CGRectMake(0, self.height, self.width, _bgView.height)];
  86. }
  87. completion:^(BOOL finished) {
  88. [self removeFromSuperview];
  89. }];
  90. }
  91. @end