// // CPDFBackgroundView.m // PDFViewer // // Created by kdanmobile_2 on 2023/1/2. // #define KBUTTON_WIDTH 28 #define KBUTTON_HEIGHT 28 #import "PDFBackgroundView.h" #import "Masonry.h" @implementation PDFBackgroundView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // _imageLabel = [[UILabel alloc] init]; // [self addSubview:_imageLabel]; // // _selectBtn = [[UIButton alloc] init]; // [self addSubview:_selectBtn]; // // _colorLabel = [[UILabel alloc] init]; // [self addSubview:_colorLabel]; // _colorArray = [NSMutableArray array]; // // [_colorArray addObject:_colorBtn1]; // [_colorArray addObject:_colorBtn2]; // [_colorArray addObject:_colorBtn3]; // [_colorArray addObject:_colorBtn4]; // [_colorArray addObject:_colorBtn5]; // [_colorArray addObject:_colorBtn6]; // [_colorArray addObject:_colorBtn7]; // [_colorArray addObject:_colorBtn8]; // for (NSInteger i = 0; i < 8; ++i) { //// _colorBtn = [UIButton buttonWithType:UIButtonTypeSystem]; //// [_colorArray addObject:_colorBtn]; //// [self addSubview:_colorBtn]; // // } self = [[NSBundle mainBundle] loadNibNamed:@"BackgroundView" owner:nil options:nil].firstObject; } return self; } //- (void)drawRect:(CGRect)rect { // [super drawRect:rect]; // _colorLabel.frame = CGRectMake(10, 5, 50, 30); // _colorLabel.text = NSLocalizedString(@"Color", nil); // _imageLabel.frame = CGRectMake(20, 40, 140, 30); // _imageLabel.text = NSLocalizedString(@"Image", nil); // for (NSInteger i = 0; i < _colorArray.count; i++) { // [[[self colorArray][i] layer] setCornerRadius:KBUTTON_WIDTH / 2]; // [[[self colorArray][i] layer] setMasksToBounds:YES]; // [[_colorArray[i] layer] setBorderWidth:0.5f]; // [[_colorArray[i] layer] setBorderColor:UIColor.grayColor.CGColor]; // } // // [_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 whiteColor]]; // // _selectBtn.layer.borderWidth = 1.0; // _selectBtn.layer.borderColor = UIColor.grayColor.CGColor; // [_selectBtn setTitle:NSLocalizedString(@"Select Image", nil) forState:UIControlStateNormal]; // [_selectBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; // _selectBtn.layer.cornerRadius = 7; // [self addConstraint]; //} //- (void)addConstraint { // NSInteger offset = 10; // for (NSInteger i = 0; i < _colorArray.count; ++i) { // [_colorArray[i] mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.equalTo(self.mas_right).offset( - offset); // make.top.equalTo(self.mas_top).offset(5); // make.width.equalTo(@KBUTTON_WIDTH); // make.height.equalTo(@KBUTTON_HEIGHT); // }]; // offset += 40; // } // // [_selectBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.equalTo(self.mas_right).offset(-25); // make.top.equalTo(self.colorLabel.mas_bottom).offset(5); // make.width.mas_equalTo(180); // make.height.equalTo(@35); // }]; //} @end