CPDFHeaderFooterTextTableView.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 = 55;
  15. [self addSubview:_tableView];
  16. // Title
  17. _titleView = [[UILabel alloc] init];
  18. _titleView.font = [UIFont systemFontOfSize:15.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. // OK
  26. _okBtn = [[UIButton alloc] init];
  27. _okBtn.backgroundColor = [UIColor systemGray5Color];
  28. [_okBtn setTitle:@"Back" forState:UIControlStateNormal];
  29. _okBtn.imageView.image = [UIImage imageNamed:@"btn_frontpage"];
  30. [self addSubview:_okBtn];
  31. }
  32. return self;
  33. }
  34. #pragma mark - Layout
  35. - (void)layoutSubviews {
  36. [super layoutSubviews];
  37. // Tableview
  38. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self.mas_top).offset(33);
  40. make.left.equalTo(self.mas_left);
  41. make.right.equalTo(self.mas_right);
  42. make.bottom.equalTo(self.mas_bottom).offset(-44);
  43. }];
  44. // Title
  45. [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.equalTo(self.mas_top);
  47. make.left.equalTo(self.mas_left);
  48. make.right.equalTo(self.mas_right);
  49. make.height.mas_equalTo(55);
  50. }];
  51. // OK
  52. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.equalTo(self.titleView.mas_top).offset(5);
  54. make.left.equalTo(self.titleView.mas_left);
  55. make.height.mas_equalTo(44);
  56. make.width.mas_equalTo(60);
  57. }];
  58. }
  59. @end