123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- //
- // CPDFTextView.m
- // PDFViewer
- //
- // Created by kdan on 2022/11/16.
- //
- #import "CPDFTextView.h"
- #import "Masonry.h"
- #define KSCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
- #define KSCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
- #define KBUTTON_WIDTH 28
- #define KBUTTON_HEIGHT 28
- @implementation CPDFTextView
- - (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];
- _textScaleSlider = [[UISlider alloc] init];
- _tileSwitch = [[UISwitch alloc] init];
- _rangeLabel = [[UILabel alloc] init];
- _tileLabel = [[UILabel alloc] init];
- _textLabel = [[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];
-
- _colorArray = [NSMutableArray array];
- for (NSInteger i = 0; i < 8; ++i) {
- _colorBtn = [UIButton buttonWithType:UIButtonTypeSystem];
- [_colorArray addObject:_colorBtn];
- [self addSubview:_colorBtn];
- }
-
-
- [self addSubview:_opacitySlider];
- [self addSubview:_textLabel];
- [self addSubview:_opacityLabel];
- [self addSubview:_textScaleSlider];
- [self addSubview:_tileSwitch];
- [self addSubview:_rangeLabel];
- [self addSubview:_tileLabel];
- [self addSubview:_verticalLabel];
- [self addSubview:_verticalField];
- [self addSubview:_horizontalField];
- [self addSubview:_horizontalLabel];
-
- [self setBackgroundColor:[UIColor whiteColor]];
-
- }
- - (void)createFrame {
- // y -- 40 height -- 30
- _opacitySlider.frame = CGRectMake(90, 40, KSCREEN_WIDTH - 100, 30);
- _textScaleSlider.frame = CGRectMake(90, 80, KSCREEN_WIDTH - 100, 30);
- _tileSwitch.frame = CGRectMake(100, 160, 10, 10);
- _rangeLabel.frame = CGRectMake(10, 120, 100, 30);
- _tileLabel.frame = CGRectMake(10, 160, 100, 30);
- _textLabel.frame = CGRectMake(10, 80, 90, 30);
- _opacityLabel.frame = CGRectMake(10, 40, 90, 30);
- _verticalLabel.frame = CGRectMake(270, 160, 20, 30);
- _verticalField.frame = CGRectMake(295, 160, 80, 30);
- _horizontalLabel.frame = CGRectMake(165, 160, 20, 30);
- _horizontalField.frame = CGRectMake(185, 160, 80, 30);
-
- NSInteger offset = 10;
- for (NSInteger i = 0; i < _colorArray.count; i++) {
- [[self colorArray][i] setFrame:CGRectMake(offset, 5, KBUTTON_WIDTH, KBUTTON_HEIGHT)];
- offset += 50;
- [[[self colorArray][i] layer] setCornerRadius:KBUTTON_WIDTH / 2];
- [[[self colorArray][i] layer] setMasksToBounds:YES];
- }
-
- [_colorArray[0] setBackgroundColor:[UIColor redColor]];
- [_colorArray[1] setBackgroundColor:[UIColor orangeColor]];
- [_colorArray[2] setBackgroundColor:[UIColor yellowColor]];
- [_colorArray[3] setBackgroundColor:[UIColor greenColor]];
- [_colorArray[4] setBackgroundColor:[UIColor blueColor]];
- [_colorArray[5] setBackgroundColor:[UIColor brownColor]];
- [_colorArray[6] setBackgroundColor:[UIColor purpleColor]];
- [_colorArray[7] setBackgroundColor:[UIColor grayColor]];
- }
- //- (void)addConstraint {
- // [self.opacityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(self).offset(10);
- // make.top.equalTo(self).offset(40);
- // make.right.equalTo(self.mas_right).offset(-10);
- // }];
- // [self.opacitySlider mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(self.mas_left).offset(90);
- // make.top.equalTo(self.mas_top).offset(40);
- // make.width.equalTo(@(KSCREEN_WIDTH - 100));
- // make.height.equalTo(@30);
- // }];
- //}
- - (void)assignData {
- _rangeLabel.text = @"Page Range";
- _tileLabel.text = @"Full Screen";
- _textLabel.text = @"Font Size";
- _opacityLabel.text = @"Opacity";
- _verticalLabel.text = @"Y:";
- _horizontalLabel.text = @"X:";
- }
- @end
|