123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //
- // HeaderFooterAddView.m
- // PDFViewer
- //
- // Created by kdanmobile_2 on 2022/11/16.
- //
- #import "CPDFHeaderFooterAddView.h"
- #import "Masonry.h"
- @implementation CPDFHeaderFooterAddView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- CGFloat offsetx = 3.5;
- if (self) {
- // Page number location
- _localLabel = [[UILabel alloc] init];
- [_localLabel setText:@"Page number position"];
- _localLabel.font = [UIFont boldSystemFontOfSize:12];
- NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
- _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
- [self addSubview:_localLabel];
- [self addSubview:_localSegment];
- [_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(130);
- 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.width.mas_equalTo(364);
- make.height.mas_equalTo(44);
- }];
-
- // Alignment
- _alignmentLabel = [[UILabel alloc] init];
- [_alignmentLabel setText:@"alignment"];
- _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
- NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
- _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
- [self addSubview:_alignmentLabel];
- [self addSubview:_aligbmentSegment];
- [_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.width.mas_equalTo(364);
- make.height.mas_equalTo(44);
- }];
-
- // Font color
- _colorLabel = [[UILabel alloc] init];
- [_colorLabel setText:@"Font Color"];
- _colorLabel.font = [UIFont boldSystemFontOfSize:12];
- _colerImage = [[UIImageView alloc] init];
- CALayer *layer = [_colerImage layer];
- layer.borderColor = [[UIColor blackColor] CGColor];
- layer.borderWidth = 0.5f;
- _colerImage.image = [UIImage imageNamed:@"text_color_bar"];
- _colorSlider = [[UISlider alloc] init];
- _colorSlider.minimumValue = 0;
- _colorSlider.maximumValue = 100;
- _colorSlider.value = 5;
- [self addSubview:_colorLabel];
- [self addSubview:_colorSlider];
- [self addSubview:_colerImage];
- [_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.width.mas_equalTo(364);
- 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.width.mas_equalTo(364);
- make.height.mas_equalTo(44);
- }];
-
- // Page number
- _pageNumberLabel = [[UILabel alloc] init];
- [_pageNumberLabel setText:@"Page Text"];
- _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
- _pageNumberText = [[UITextField alloc] init];
- _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
- _pageNumberText.placeholder = @"text";
- [self addSubview:_pageNumberLabel];
- [self addSubview:_pageNumberText];
- [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
- make.left.equalTo(self.mas_left).offset(offsetx);
- make.height.mas_equalTo(44);
- make.width.mas_equalTo(73);
- }];
- [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
- make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
- make.height.mas_equalTo(44);
- make.width.mas_equalTo(93);
- }];
-
- // Font size
- _fontSizeLabel = [[UILabel alloc] init];
- [_fontSizeLabel setText:@"Font Szie"];
- _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
- _fontSizeText = [[UITextField alloc] init];
- _fontSizeText.borderStyle = UITextBorderStyleRoundedRect;
- _fontSizeText.placeholder = @"18.0";
- _fontSizeText.keyboardType = UIKeyboardTypeDefault;
- _fontSizeText.delegate = self;
- [self addSubview:_fontSizeLabel];
- [self addSubview:_fontSizeText];
- [_fontSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
- make.left.equalTo(_pageNumberText.mas_right).offset(offsetx + 20);
- make.height.mas_equalTo(44);
- make.width.mas_equalTo(73);
- }];
- [_fontSizeText mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
- make.left.equalTo(_fontSizeLabel.mas_right).offset(offsetx);
- make.height.mas_equalTo(44);
- make.width.mas_equalTo(93);
- }];
-
- // Font index
- _pageIndexLabel = [[UILabel alloc] init];
- [_pageIndexLabel setText:@"Page Start"];
- _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
- _pageIndexNumberText = [[UITextField alloc] init];
- _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
- _pageIndexNumberText.placeholder = @"1";
- [self addSubview:_pageIndexLabel];
- [self addSubview:_pageIndexNumberText];
- [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_pageNumberLabel.mas_bottom).offset(offsetx);
- make.left.equalTo(self.mas_left).offset(offsetx);
- make.height.mas_equalTo(44);
- make.width.mas_equalTo(73);
- }];
- [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_pageNumberText.mas_bottom).offset(offsetx+5);
- make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
- make.height.mas_equalTo(33);
- make.width.mas_equalTo(93);
- }];
- self.backgroundColor = [UIColor whiteColor];
- }
- return self;
- }
- #pragma mark - UITextFieldDelegate
- - (BOOL)textFieldShouldReturn:(UITextField *)textField {
- [_pageNumberText resignFirstResponder];
- return YES;
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- NSString *number = kNumber;
- NSPredicate *numberPre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",number];
- return [numberPre evaluateWithObject:string];
- }
- @end
|