PDFBackgroundPreview.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // CPDFBackgroundPreview.m
  3. // PDFViewer
  4. //
  5. // Created by kdanmobile_2 on 2023/1/2.
  6. //
  7. #import "PDFBackgroundPreview.h"
  8. #import "Masonry.h"
  9. @implementation PDFBackgroundPreview
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. [self addSubview:self.preImageView];
  14. self.backgroundColor = [UIColor grayColor];
  15. }
  16. return self;
  17. }
  18. - (void)drawRect:(CGRect)rect {
  19. [super drawRect:rect];
  20. self.preImageView.layer.borderColor = UIColor.blueColor.CGColor;
  21. self.preImageView.layer.borderWidth = 1;
  22. [self.preImageView sizeToFit];
  23. self.preImageView.contentMode = UIViewContentModeScaleAspectFit;
  24. CGRect frame = self.preImageView.frame;
  25. 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);
  26. self.preImageView.frame = frame;
  27. }
  28. @end