// // CPDFBackgroundSettingView.m // PDFViewer // // Created by kdanmobile_2 on 2023/1/2. // #import "CPDFBackgroundSettingView.h" #import "Masonry.h" @implementation CPDFBackgroundSettingView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { _opacitySlider = [[UISlider alloc] init]; _scaleSlider = [[UISlider alloc] init]; _rotationSlider = [[UISlider alloc] init]; [self addSubview:_opacitySlider]; [self addSubview:_scaleSlider]; [self addSubview:_rotationSlider]; _rotationlabel = [[UILabel alloc] init]; _rangeLabel = [[UILabel alloc] init]; _textLabel = [[UILabel alloc] init]; _opacityLabel = [[UILabel alloc] init]; _titleLabel = [[UILabel alloc] init]; [self addSubview:_textLabel]; [self addSubview:_opacityLabel]; [self addSubview:_rangeLabel]; [self addSubview:_rotationlabel]; [self addSubview:_titleLabel]; _verticalField = [[UITextField alloc] init]; _verticalField.borderStyle = UITextBorderStyleRoundedRect; _verticalLabel = [[UILabel alloc] init]; _horizontalField = [[UITextField alloc] init]; _horizontalField.borderStyle = UITextBorderStyleRoundedRect; _horizontalLabel = [[UILabel alloc] init]; _pageBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [self addSubview:_verticalLabel]; [self addSubview:_verticalField]; [self addSubview:_horizontalField]; [self addSubview:_horizontalLabel]; [self addSubview:_pageBtn]; _doneBtn = [[UIButton alloc] init]; _cancelBtn = [[UIButton alloc] init]; [self addSubview:_doneBtn]; [self addSubview:_cancelBtn]; self.backgroundColor = [UIColor systemGray6Color]; } return self; } - (void)drawRect:(CGRect)rect { _titleLabel.frame = CGRectMake(5, 5, 180, 50); _rangeLabel.frame = CGRectMake(5, 165, 150, 30); _textLabel.frame = CGRectMake(5, 95, 90, 30); _opacityLabel.frame = CGRectMake(5, 60, 90, 30); _rotationlabel.frame = CGRectMake(5, 130, 90, 30); [self addConstraint]; [self assignData]; } - (void)addConstraint { [_verticalField mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.top.equalTo(self.pageBtn.mas_bottom).offset(10); make.width.equalTo(@80); make.height.equalTo(@30); }]; [_verticalLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-95); make.top.equalTo(self.pageBtn.mas_bottom).offset(10); make.width.equalTo(@20); make.height.equalTo(@30); }]; [_horizontalField mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(25); make.top.equalTo(self.pageBtn.mas_bottom).offset(10); make.width.equalTo(@80); make.height.equalTo(@30); }]; [_horizontalLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(5); make.top.equalTo(self.pageBtn.mas_bottom).offset(10); make.width.equalTo(@20); make.height.equalTo(@30); }]; [_scaleSlider mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.left.equalTo(_textLabel.mas_right).offset(0); make.top.equalTo(self.mas_top).offset(95); make.height.equalTo(@30); }]; [_opacitySlider mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.left.equalTo(_opacityLabel.mas_right).offset(0); make.top.equalTo(self.mas_top).offset(60); make.height.equalTo(@30); }]; [_rotationSlider mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.left.equalTo(_rotationlabel.mas_right).offset(0); make.top.equalTo(_scaleSlider.mas_bottom).offset(5); }]; [_pageBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.top.equalTo(self.rotationSlider.mas_bottom).offset(5); make.left.equalTo(_rangeLabel.mas_right); make.height.equalTo(@35); }]; [_doneBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.top.equalTo(_horizontalField.mas_bottom).offset(25); make.height.mas_equalTo(30); make.width.mas_equalTo(80); }]; [_cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-110); make.top.equalTo(_horizontalField.mas_bottom).offset(25); make.height.mas_equalTo(30); make.width.mas_equalTo(80); }]; } - (void)assignData { _rangeLabel.text = @"Page Range"; _rangeLabel.font = [UIFont systemFontOfSize:15]; _titleLabel.text = @"Background Edit"; _rotationlabel.text = @"Rotation"; _textLabel.text = @"Scale"; _opacityLabel.text = @"Opacity"; _verticalLabel.text = @"Y:"; _horizontalLabel.text = @"X:"; _scaleSlider.minimumValue = 0.2; _scaleSlider.maximumValue = 1; _scaleSlider.value = 1; _rotationSlider.minimumValue = 0; _rotationSlider.maximumValue = M_PI; [_pageBtn setTitle:@"Page Range" forState:UIControlStateNormal]; [_doneBtn setTitle:@"Done" forState:UIControlStateNormal]; [_doneBtn setTitleColor:UIColor.systemBlueColor forState:UIControlStateNormal]; [_cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal]; [_cancelBtn setTitleColor:UIColor.systemBlueColor forState:UIControlStateNormal]; } @end