CPDFHeaderFooterTextTableView.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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
  13. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  14. _tableView.rowHeight = 33;
  15. [self addSubview:_tableView];
  16. // Title
  17. _titleView = [[UILabel alloc] init];
  18. _titleView.font = [UIFont systemFontOfSize:12.0f];
  19. _titleView.textColor = [UIColor blackColor];
  20. _titleView.backgroundColor = [UIColor systemGray5Color];
  21. _titleView.text = titleName;
  22. _titleView.textAlignment = NSTextAlignmentCenter;
  23. _titleView.textColor = [UIColor whiteColor];
  24. [self addSubview:_titleView];
  25. // View button at the bottom
  26. _bottomView = [[UIView alloc] init];
  27. _bottomView.backgroundColor = [UIColor systemGray5Color];
  28. [self addSubview:_bottomView];
  29. // OK
  30. _okBtn = [[UIButton alloc] init];
  31. [_okBtn setTitle:@"OK" forState:UIControlStateNormal];
  32. _okBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  33. _okBtn.backgroundColor = [UIColor systemGray3Color];
  34. }
  35. return self;
  36. }
  37. #pragma mark - Layout
  38. - (void)layoutSubviews {
  39. [super layoutSubviews];
  40. // Tableview
  41. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self.mas_top).offset(33);
  43. make.left.equalTo(self.mas_left);
  44. make.right.equalTo(self.mas_right);
  45. make.bottom.equalTo(self.mas_bottom).offset(-44);
  46. }];
  47. // Title
  48. [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.equalTo(self.mas_top);
  50. make.left.equalTo(self.mas_left);
  51. make.right.equalTo(self.mas_right);
  52. make.height.mas_equalTo(33);
  53. }];
  54. // View button at the bottom
  55. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.equalTo(self.tableView.mas_bottom);
  57. make.left.equalTo(self.mas_left);
  58. make.right.equalTo(self.mas_right);
  59. make.height.mas_equalTo(44);
  60. }];
  61. // OK
  62. [self.bottomView addSubview:_okBtn];
  63. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.equalTo(self.bottomView.mas_top).offset(6);
  65. make.right.equalTo(self.bottomView.mas_right).offset(-60);
  66. make.height.mas_equalTo(33);
  67. make.width.mas_equalTo(40);
  68. }];
  69. }
  70. @end