CPDFHeaderFooterTextTableView.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. - (void)layoutSubviews {
  38. [super layoutSubviews];
  39. // Tableview
  40. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.equalTo(self.mas_top).offset(33);
  42. make.left.equalTo(self.mas_left);
  43. make.right.equalTo(self.mas_right);
  44. make.bottom.equalTo(self.mas_bottom).offset(-44);
  45. }];
  46. // Title
  47. [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.equalTo(self.mas_top);
  49. make.left.equalTo(self.mas_left);
  50. make.right.equalTo(self.mas_right);
  51. make.height.mas_equalTo(33);
  52. }];
  53. // View button at the bottom
  54. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.equalTo(self.tableView.mas_bottom);
  56. make.left.equalTo(self.mas_left);
  57. make.right.equalTo(self.mas_right);
  58. make.height.mas_equalTo(44);
  59. }];
  60. // OK
  61. [self.bottomView addSubview:_okBtn];
  62. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.top.equalTo(self.bottomView.mas_top).offset(6);
  64. make.right.equalTo(self.bottomView.mas_right).offset(-60);
  65. make.height.mas_equalTo(33);
  66. make.width.mas_equalTo(40);
  67. }];
  68. }
  69. @end