// // CPDFAddView.m // PDFViewer // // Created by kdanmobile_2 on 2022/12/5. // #import "PDFAddView.h" #import "Masonry.h" @implementation PDFAddView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { _localLabel = [[UILabel alloc] init]; NSArray *arraySegmmentL = [NSArray arrayWithObjects:NSLocalizedString(@"Header", nil), NSLocalizedString(@"Footer", nil), nil]; _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL]; [self addSubview:_localLabel]; [self addSubview:_localSegment]; // Alignment _alignmentLabel = [[UILabel alloc] init]; NSArray *arraySegmmentA = [NSArray arrayWithObjects:NSLocalizedString(@"Left", nil), NSLocalizedString(@"Center", nil), NSLocalizedString(@"Right", nil), nil]; _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA]; [self addSubview:_alignmentLabel]; [self addSubview:_aligbmentSegment]; // Font color _colorLabel = [[UILabel alloc] init]; _colerImage = [[UIImageView alloc] init]; _colorSlider = [[UISlider alloc] init]; [self addSubview:_colorLabel]; [self addSubview:_colorSlider]; [self addSubview:_colerImage]; } return self; } #pragma mark - Layout - (void)layoutSubviews { [super layoutSubviews]; CGFloat offsetx = 3.5; // Page number location [_localLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.mas_top).offset(offsetx); make.left.equalTo(self.mas_left).offset(offsetx); make.width.mas_equalTo(150); make.height.mas_equalTo(22); }]; [_localSegment mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_localLabel.mas_bottom).offset(offsetx); make.left.equalTo(self.mas_left).offset(4 * offsetx); make.right.equalTo(self.mas_right).offset(-4 *offsetx); make.height.mas_equalTo(44); }]; // Alignment [_alignmentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_localSegment.mas_bottom).offset(offsetx); make.left.equalTo(self.mas_left).offset(offsetx); make.width.mas_equalTo(100); make.height.mas_equalTo(22); }]; [_aligbmentSegment mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_alignmentLabel.mas_bottom).offset(offsetx); make.left.equalTo(self.mas_left).offset(4 * offsetx); make.right.equalTo(self.mas_right).offset(-4 *offsetx); make.height.mas_equalTo(44); }]; // Font color [_colorLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_aligbmentSegment.mas_bottom).offset(offsetx); make.left.equalTo(self.mas_left).offset(offsetx); make.width.mas_equalTo(100); make.height.mas_equalTo(22); }]; [_colerImage mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_colorLabel.mas_bottom).offset(offsetx); make.left.equalTo(self.mas_left).offset(4 * offsetx); make.right.equalTo(self.mas_right).offset(-4 *offsetx); make.height.mas_equalTo(44); }]; [_colorSlider mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_colerImage.mas_bottom).offset(offsetx); make.left.equalTo(self.mas_left).offset(4 * offsetx); make.right.equalTo(self.mas_right).offset(-4 *offsetx); make.height.mas_equalTo(34); }]; } @end