CPDFHeaderFooterTextTableView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // CPDFHeaderFooterTextTableView.m
  3. // PDFViewer
  4. //
  5. // Created by kdanmobile_2 on 2022/11/25.
  6. //
  7. #import "CPDFHeaderFooterTextTableView.h"
  8. @implementation CPDFHeaderFooterTextTableView
  9. - (instancetype)initWithTitleName:(NSString *)titleName {
  10. self = [super init];
  11. if (self) {
  12. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  13. _tableView.rowHeight = 33;
  14. [self addSubview:_tableView];
  15. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  16. make.top.equalTo(self.mas_top).offset(33);
  17. make.left.equalTo(self.mas_left);
  18. make.right.equalTo(self.mas_right);
  19. make.bottom.equalTo(self.mas_bottom).offset(-44);
  20. }];
  21. // Title
  22. _titleView = [[UILabel alloc] init];
  23. _titleView.font = [UIFont systemFontOfSize:12.0f];
  24. _titleView.textColor = [UIColor blackColor];
  25. _titleView.backgroundColor = [UIColor systemGray5Color];
  26. _titleView.text = titleName;
  27. _titleView.textAlignment = NSTextAlignmentCenter;
  28. _titleView.textColor = [UIColor whiteColor];
  29. [self addSubview:_titleView];
  30. [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.equalTo(self.mas_top);
  32. make.left.equalTo(self.mas_left);
  33. make.right.equalTo(self.mas_right);
  34. make.height.mas_equalTo(33);
  35. }];
  36. // View button at the bottom
  37. _bottomView = [[UIView alloc] init];
  38. _bottomView.backgroundColor = [UIColor systemGray5Color];
  39. [self addSubview:_bottomView];
  40. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.equalTo(self.tableView.mas_bottom);
  42. make.left.equalTo(self.mas_left);
  43. make.right.equalTo(self.mas_right);
  44. make.height.mas_equalTo(44);
  45. }];
  46. // OK
  47. _okBtn = [[UIButton alloc] init];
  48. [_okBtn setTitle:@"OK" forState:UIControlStateNormal];
  49. _okBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  50. _okBtn.backgroundColor = [UIColor systemGray3Color];
  51. [self.bottomView addSubview:_okBtn];
  52. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.equalTo(self.bottomView.mas_top).offset(6);
  54. make.right.equalTo(self.bottomView.mas_right).offset(-60);
  55. make.height.mas_equalTo(33);
  56. make.width.mas_equalTo(40);
  57. }];
  58. // Cancel
  59. _cancelBtn = [[UIButton alloc] initWithFrame:CGRectZero];
  60. [_cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal];
  61. _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  62. _cancelBtn.backgroundColor = [UIColor systemGray3Color];
  63. [self.bottomView addSubview:_cancelBtn];
  64. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self.bottomView.mas_top).offset(6);
  66. make.right.equalTo(self.bottomView.mas_right).offset(-10);
  67. make.height.mas_equalTo(33);
  68. make.width.mas_equalTo(40);
  69. }];
  70. }
  71. return self;
  72. }
  73. @end