123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- //
- // CPDFImageView.m
- // PDFViewer
- //
- // Created by kdan on 2022/11/16.
- //
- #import "CPDFImageView.h"
- #import "Masonry.h"
- @implementation CPDFImageView
- - (instancetype)initWithFrame:(CGRect)frame {
-
- if (self = [super initWithFrame:frame]) {
- [self createView];
- [self assignData];
- }
-
- return self;
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
- [self createFrame];
- [self addConstraint];
- }
- - (void)createView {
-
- _opacitySlider = [[UISlider alloc] init];
- _imageScaleSlider = [[UISlider alloc] init];
- _tileSwitch = [[UISwitch alloc] init];
- _rangeLabel = [[UILabel alloc] init];
- _tileLabel = [[UILabel alloc] init];
- _sizeLabel = [[UILabel alloc] init];
- _opacityLabel = [[UILabel alloc] init];
-
- _verticalField = [[UITextField alloc] init];
- _verticalField.borderStyle = UITextBorderStyleRoundedRect;
-
- _verticalLabel = [[UILabel alloc] init];
-
- _horizontalField = [[UITextField alloc] init];
- _horizontalField.borderStyle = UITextBorderStyleRoundedRect;
-
- _horizontalLabel = [[UILabel alloc] init];
- _imageLabel = [[UILabel alloc] init];
- _selectBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- _pageBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
-
- [self addSubview:_opacitySlider];
- [self addSubview:_sizeLabel];
- [self addSubview:_opacityLabel];
- [self addSubview:_imageScaleSlider];
- [self addSubview:_tileSwitch];
- [self addSubview:_rangeLabel];
- [self addSubview:_tileLabel];
- [self addSubview:_verticalLabel];
- [self addSubview:_verticalField];
- [self addSubview:_horizontalField];
- [self addSubview:_horizontalLabel];
- [self addSubview:_imageLabel];
- [self addSubview:_selectBtn];
- [self addSubview:_pageBtn];
-
- [self setBackgroundColor:[UIColor whiteColor]];
-
- }
- - (void)createFrame {
- // y -- 40 height -- 30
- _tileSwitch.frame = CGRectMake(100, 160, 10, 10);
- _rangeLabel.frame = CGRectMake(10, 120, 180, 30);
- _tileLabel.frame = CGRectMake(10, 160, 100, 30);
- _sizeLabel.frame = CGRectMake(10, 80, 90, 30);
- _opacityLabel.frame = CGRectMake(10, 40, 90, 30);
- _imageLabel.frame = CGRectMake(10, 5, 150, 30);
-
- _selectBtn.layer.borderWidth = 1.0;
- _selectBtn.layer.borderColor = UIColor.systemGray4Color.CGColor;
- [_selectBtn setTitle:@"Select Image" forState:UIControlStateNormal];
- [_selectBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
- _selectBtn.layer.cornerRadius = 7;
-
- _pageBtn.layer.borderWidth = 1.0;
- _pageBtn.layer.borderColor = UIColor.systemGray4Color.CGColor;
- [_pageBtn setTitle:@"Page Range" forState:UIControlStateNormal];
- [_pageBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
- _pageBtn.layer.cornerRadius = 7;
- }
- - (void)addConstraint {
- [_verticalField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-15);
- make.bottom.equalTo(self.mas_bottom).offset(-15);
- make.width.equalTo(@80);
- make.height.equalTo(@30);
- }];
- [_verticalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-95);
- make.bottom.equalTo(self.mas_bottom).offset(-15);
- make.width.equalTo(@20);
- make.height.equalTo(@30);
- }];
- [_horizontalField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-115);
- make.bottom.equalTo(self.mas_bottom).offset(-15);
- make.width.equalTo(@80);
- make.height.equalTo(@30);
- }];
- [_horizontalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-195);
- make.bottom.equalTo(self.mas_bottom).offset(-15);
- make.width.equalTo(@20);
- make.height.equalTo(@30);
- }];
- [_selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-15);
- make.top.equalTo(self.mas_top).offset(2);
- make.left.equalTo(_horizontalField.mas_left);
- make.height.equalTo(@35);
- }];
- [_imageScaleSlider mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-15);
- make.left.equalTo(_sizeLabel.mas_right).offset(0);
- make.top.equalTo(self.mas_top).offset(80);
- 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(40);
- make.height.equalTo(@30);
- }];
- [_pageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.mas_right).offset(-15);
- make.top.equalTo(self.mas_top).offset(115);
- make.left.equalTo(_horizontalField.mas_left);
- make.height.equalTo(@35);
- }];
- }
- - (void)assignData {
- _rangeLabel.text = @"Page Range";
- _tileLabel.text = @"Full Screen";
- _sizeLabel.text = @"Image Size";
- _opacityLabel.text = @"Opacity";
- _verticalLabel.text = @"Y:";
- _horizontalLabel.text = @"X:";
- _imageLabel.text = @"Image";
- }
- @end
|