MGGroupBottomCellView.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // MGGroupBottomCellView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2019/4/23.
  6. // Copyright © 2019年 xfg. All rights reserved.
  7. //
  8. #import "MGGroupBottomCellView.h"
  9. @implementation MGGroupBottomCellView
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if (self) {
  14. [self setUpView];
  15. }
  16. return self;
  17. }
  18. - (instancetype)initWithFrame:(CGRect)frame
  19. {
  20. self = [super initWithFrame:frame];
  21. if (self) {
  22. [self setUpView];
  23. }
  24. return self;
  25. }
  26. -(void)setUpView
  27. {
  28. NSArray *imgArr = @[@"mg_dy_comment",@"mg_dy_likes",@""];
  29. NSArray *titleArr = @[@"0",@"0",ASLocalizedString(@"转发")];
  30. for (int i = 0; i < 3; i ++) {
  31. QMUIButton *but = [QMUIButton buttonWithType:UIButtonTypeCustom];
  32. but.frame = CGRectMake(50 * i, 0, 50, 30);
  33. but.tag = 10 + i;
  34. but.spacingBetweenImageAndTitle = 5;
  35. but.backgroundColor = [UIColor colorWithHexString:@"4b5255"];
  36. but.titleLabel.font = [UIFont systemFontOfSize:13];
  37. [but setTitleColor:kWhiteColor forState:UIControlStateNormal];
  38. [but setTitle:titleArr[i] forState:UIControlStateNormal];
  39. [but setImage:[UIImage imageNamed:imgArr[i]] forState:UIControlStateNormal];
  40. [but addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
  41. but.imagePosition = QMUIButtonImagePositionLeft;
  42. [self addSubview:but];
  43. if (i == 0) {
  44. self.btnComment = but;
  45. }else if (i == 1){
  46. self.btnLike = but;
  47. }
  48. }
  49. }
  50. -(void)clickBtn:(UIButton *)sender{
  51. NSInteger tag = sender.tag;
  52. if (tag == 10) {
  53. if([self.delegate respondsToSelector:@selector(onComment)])
  54. {
  55. [self.delegate onComment];
  56. }
  57. }else if (tag == 11){
  58. if([self.delegate respondsToSelector:@selector(onLike)])
  59. {
  60. [self.delegate onLike];
  61. }
  62. }else if (tag == 12){
  63. if([self.delegate respondsToSelector:@selector(onShare)])
  64. {
  65. [self.delegate onShare];
  66. }
  67. }
  68. }
  69. -(void)resetBottomViewWithComment:(NSString *)comment likes:(NSString *)likes
  70. {
  71. // QMUIButton *commentBtn = [self viewWithTag:10];
  72. // QMUIButton *likeBtn = [self viewWithTag:11];
  73. //
  74. [self.btnLike setTitle:likes forState:UIControlStateNormal];
  75. [self.btnComment setTitle:comment forState:UIControlStateNormal];
  76. }
  77. @end