ChatBatchView.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // ChatBatchView.m
  3. // AIIM
  4. //
  5. // Created by qitewei on 2025/5/10.
  6. //
  7. #import "ChatBatchView.h"
  8. @interface ChatBatchView()
  9. @property (nonatomic, strong) UILabel * closeTitle;
  10. @property (nonatomic, strong) UILabel * multipleTitle;
  11. @property (nonatomic, strong) UILabel * singleTitle;
  12. @property (nonatomic, strong) UILabel * deleteTitle;
  13. @property (nonatomic, copy) NSArray * images;
  14. @property (nonatomic, strong) NSMutableArray * labels;
  15. @end
  16. @implementation ChatBatchView
  17. - (instancetype)initWithFrame:(CGRect)frame{
  18. if (self=[super initWithFrame:frame]) {
  19. self.backgroundColor = UIColor.whiteColor;
  20. [self configUI];
  21. }
  22. return self;
  23. }
  24. - (void)configUI{
  25. NSMutableArray * buttons = [NSMutableArray array];
  26. for (NSString * imageName in self.images) {
  27. UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
  28. button.tag = [self.images indexOfObject:imageName]+3000;
  29. [button setImage:kImageMake(imageName) forState:UIControlStateNormal];
  30. [button addTarget:self action:@selector(batchButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  31. [self addSubview:button];
  32. [buttons addObject:button];
  33. [button mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.height.mas_equalTo(40);
  35. make.top.mas_equalTo(10);
  36. }];
  37. }
  38. [buttons mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:(SCREEN_WIDTH-220)/3.f leadSpacing:30 tailSpacing:30];
  39. for (int i = 0; i < self.labels.count; i++) {
  40. UIButton * button = buttons[i];
  41. UILabel * label = self.labels[i];
  42. [self addSubview:label];
  43. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.height.mas_equalTo(16);
  45. make.top.mas_equalTo(button.mas_bottom).offset(8);
  46. make.centerX.mas_equalTo(button.mas_centerX);
  47. }];
  48. }
  49. }
  50. #pragma mark event
  51. - (void)batchButtonClicked:(UIButton *)sender{
  52. NSInteger index = sender.tag-3000;
  53. if (self.indexOfBatchClicked) {
  54. self.indexOfBatchClicked(index);
  55. }
  56. }
  57. #pragma mark lazy
  58. - (UILabel *)closeTitle{
  59. if (!_closeTitle) {
  60. _closeTitle = [[UILabel alloc] init];
  61. _closeTitle.text = @"取消";
  62. _closeTitle.textColor = UIColor.blackColor;
  63. _closeTitle.textAlignment = NSTextAlignmentCenter;
  64. _closeTitle.font = SYSFONT(16);
  65. }
  66. return _closeTitle;
  67. }
  68. - (UILabel *)multipleTitle{
  69. if (!_multipleTitle) {
  70. _multipleTitle = [[UILabel alloc] init];
  71. _multipleTitle.text = @"合并转发";
  72. _multipleTitle.textColor = UIColor.blackColor;
  73. _multipleTitle.textAlignment = NSTextAlignmentCenter;
  74. _multipleTitle.font = SYSFONT(16);
  75. }
  76. return _multipleTitle;
  77. }
  78. - (UILabel *)singleTitle{
  79. if (!_singleTitle) {
  80. _singleTitle = [[UILabel alloc] init];
  81. _singleTitle.text = @"逐条转发";
  82. _singleTitle.textColor = UIColor.blackColor;
  83. _singleTitle.textAlignment = NSTextAlignmentCenter;
  84. _singleTitle.font = SYSFONT(16);
  85. }
  86. return _singleTitle;
  87. }
  88. - (UILabel *)deleteTitle{
  89. if (!_deleteTitle) {
  90. _deleteTitle = [[UILabel alloc] init];
  91. _deleteTitle.text = @"删除";
  92. _deleteTitle.textColor = UIColor.blackColor;
  93. _deleteTitle.textAlignment = NSTextAlignmentCenter;
  94. _deleteTitle.font = SYSFONT(16);
  95. }
  96. return _deleteTitle;
  97. }
  98. - (NSArray *)images{
  99. if (!_images) {
  100. _images = @[@"close",@"hebingzhuanfa",@"zhuanfa",@"shanchu"];
  101. }
  102. return _images;
  103. }
  104. - (NSMutableArray *)labels{
  105. if (!_labels) {
  106. _labels = [NSMutableArray arrayWithArray:@[self.closeTitle,self.multipleTitle,self.singleTitle,self.deleteTitle]];
  107. }
  108. return _labels;
  109. }
  110. @end