BogoSquarePopView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // BogoSquarePopView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/7/31.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoSquarePopView.h"
  9. #import "BogoSquarrePopCell.h"
  10. @implementation BogoSquarePopView
  11. - (instancetype)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. // self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
  16. [self setUpView];
  17. }
  18. return self;
  19. }
  20. -(void)setUpView{
  21. [self addSubview:self.tableView];
  22. self.tableView.top = kRealValue(10);
  23. [self addSubview:self.topView];
  24. }
  25. - (void)setListArr:(NSArray *)listArr{
  26. _listArr = listArr;
  27. self.tableView.height = kRealValue(40 * listArr.count);
  28. [self.tableView reloadData];
  29. }
  30. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  31. return 1;
  32. }
  33. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  34. return self.listArr.count;
  35. }
  36. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  37. return kRealValue(40);
  38. }
  39. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  40. // static NSString *identifier = @"cell";
  41. BogoSquarrePopCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BogoSquarrePopCell"];
  42. // if (!cell) {
  43. // cell = [[BogoSquarrePopCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  44. // }
  45. cell.titleL.text = self.listArr[indexPath.row];
  46. cell.line.hidden = indexPath.row == 1;
  47. // cell.textLabel.text = self.listArr[indexPath.row];
  48. // cell.textLabel.font = [UIFont systemFontOfSize:14];
  49. // cell.textLabel.textColor = [UIColor colorWithHexString:@"#333333"];
  50. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  51. return cell;
  52. }
  53. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  54. if (self.clickIndexBlock) {
  55. self.clickIndexBlock(indexPath.row);
  56. }
  57. [self hide];
  58. }
  59. -(UITableView *)tableView{
  60. if (!_tableView) {
  61. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.width, kRealValue(80)) style:UITableViewStylePlain];
  62. _tableView.layer.cornerRadius = 5;
  63. _tableView.layer.masksToBounds = YES;
  64. _tableView.delegate = self;
  65. _tableView.dataSource = self;
  66. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  67. [_tableView registerNib:[UINib nibWithNibName:@"BogoSquarrePopCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"BogoSquarrePopCell"];
  68. // [_tableView registerClass:[BogoSquarrePopCell class] forCellReuseIdentifier:@"BogoSquarrePopCell"];
  69. }
  70. return _tableView;
  71. }
  72. -(BogoDrawView *)topView{
  73. if (!_topView) {
  74. CGFloat viewWidth = kRealValue(25);
  75. _topView = [[BogoDrawView alloc]initStartPoint:CGPointMake(0, kRealValue(10)) middlePoint:CGPointMake(viewWidth / 2,0) endPoint:CGPointMake(viewWidth, kRealValue(10)) color:kWhiteColor];
  76. _topView.frame = CGRectMake(self.right - kRealValue(10 + 10) - kRealValue(15), 0, kRealValue(10 + 10 + 10), kRealValue(10));
  77. }
  78. return _topView;
  79. }
  80. @end