PDFAddView.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // CPDFAddView.m
  3. // PDFViewer
  4. //
  5. // Created by kdanmobile_2 on 2022/12/5.
  6. //
  7. #import "PDFAddView.h"
  8. #import "Masonry.h"
  9. @implementation PDFAddView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. _localLabel = [[UILabel alloc] init];
  14. NSArray *arraySegmmentL = [NSArray arrayWithObjects:NSLocalizedString(@"Header", nil), NSLocalizedString(@"Footer", nil), nil];
  15. _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
  16. [self addSubview:_localLabel];
  17. [self addSubview:_localSegment];
  18. // Alignment
  19. _alignmentLabel = [[UILabel alloc] init];
  20. NSArray *arraySegmmentA = [NSArray arrayWithObjects:NSLocalizedString(@"Left", nil), NSLocalizedString(@"Center", nil), NSLocalizedString(@"Right", nil), nil];
  21. _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
  22. [self addSubview:_alignmentLabel];
  23. [self addSubview:_aligbmentSegment];
  24. // Font color
  25. _colorLabel = [[UILabel alloc] init];
  26. _colerImage = [[UIImageView alloc] init];
  27. _colorSlider = [[UISlider alloc] init];
  28. [self addSubview:_colorLabel];
  29. [self addSubview:_colorSlider];
  30. [self addSubview:_colerImage];
  31. }
  32. return self;
  33. }
  34. #pragma mark - Layout
  35. - (void)layoutSubviews {
  36. [super layoutSubviews];
  37. CGFloat offsetx = 3.5;
  38. // Page number location
  39. [_localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.equalTo(self.mas_top).offset(offsetx);
  41. make.left.equalTo(self.mas_left).offset(offsetx);
  42. make.width.mas_equalTo(150);
  43. make.height.mas_equalTo(22);
  44. }];
  45. [_localSegment mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.equalTo(_localLabel.mas_bottom).offset(offsetx);
  47. make.left.equalTo(self.mas_left).offset(4 * offsetx);
  48. make.right.equalTo(self.mas_right).offset(-4 *offsetx);
  49. make.height.mas_equalTo(44);
  50. }];
  51. // Alignment
  52. [_alignmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.equalTo(_localSegment.mas_bottom).offset(offsetx);
  54. make.left.equalTo(self.mas_left).offset(offsetx);
  55. make.width.mas_equalTo(100);
  56. make.height.mas_equalTo(22);
  57. }];
  58. [_aligbmentSegment mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(_alignmentLabel.mas_bottom).offset(offsetx);
  60. make.left.equalTo(self.mas_left).offset(4 * offsetx);
  61. make.right.equalTo(self.mas_right).offset(-4 *offsetx);
  62. make.height.mas_equalTo(44);
  63. }];
  64. // Font color
  65. [_colorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.equalTo(_aligbmentSegment.mas_bottom).offset(offsetx);
  67. make.left.equalTo(self.mas_left).offset(offsetx);
  68. make.width.mas_equalTo(100);
  69. make.height.mas_equalTo(22);
  70. }];
  71. [_colerImage mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.top.equalTo(_colorLabel.mas_bottom).offset(offsetx);
  73. make.left.equalTo(self.mas_left).offset(4 * offsetx);
  74. make.right.equalTo(self.mas_right).offset(-4 *offsetx);
  75. make.height.mas_equalTo(44);
  76. }];
  77. [_colorSlider mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.equalTo(_colerImage.mas_bottom).offset(offsetx);
  79. make.left.equalTo(self.mas_left).offset(4 * offsetx);
  80. make.right.equalTo(self.mas_right).offset(-4 *offsetx);
  81. make.height.mas_equalTo(34);
  82. }];
  83. }
  84. @end