// // CPDFHeadView.m // PDFViewer // // Created by kdanmobile_2 on 2022/12/7. // #import "CPDFHeadView.h" @implementation CPDFHeadView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { _imageView = [[UIImageView alloc] init]; _imageView.image = self.image; CALayer *layer = [_imageView layer]; layer.borderColor = [[UIColor blackColor] CGColor]; layer.borderWidth = 0.5f; [self addSubview:_imageView]; _showLabel = [[UILabel alloc] init]; [_showLabel setText:@"1"]; _showLabel.font = [UIFont systemFontOfSize:6]; [self.imageView addSubview:self.showLabel]; } return self; } - (void)drawRect:(CGRect)rect { [super drawRect:rect]; [_imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.mas_top); make.left.equalTo(self.mas_left); make.width.mas_equalTo(self.image.size.width / 9); make.height.mas_equalTo(self.image.size.height / 9); }]; [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_imageView.mas_top).offset(0.5); make.left.equalTo(self.imageView.mas_left).offset(0.5); make.height.mas_equalTo(10); make.width.mas_equalTo(20); }]; } @end