// // CPDFBackgroundPreview.m // PDFViewer // // Created by kdanmobile_2 on 2023/1/2. // #import "PDFBackgroundPreview.h" #import "Masonry.h" @implementation PDFBackgroundPreview - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self addSubview:self.preImageView]; self.backgroundColor = [UIColor grayColor]; } return self; } - (void)drawRect:(CGRect)rect { [super drawRect:rect]; self.preImageView.layer.borderColor = UIColor.blueColor.CGColor; self.preImageView.layer.borderWidth = 1; [self.preImageView sizeToFit]; self.preImageView.contentMode = UIViewContentModeScaleAspectFit; CGRect frame = self.preImageView.frame; frame.origin = CGPointMake(self.documentImageView.bounds.size.width / 2 - self.preImageView.frame.size.width / 2, self.documentImageView.bounds.size.height / 2 - self.preImageView.frame.size.height / 2); self.preImageView.frame = frame; } @end