CPDFImagePreview.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // CPDFImagePreview.m
  3. // PDFViewer
  4. //
  5. // Created by kdan on 2022/11/18.
  6. //
  7. #import "CPDFImagePreview.h"
  8. #import "Masonry.h"
  9. @implementation CPDFImagePreview
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. if (self = [super initWithFrame:frame]) {
  13. _watermarkView = [[UIImageView alloc] init];
  14. _rotationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  15. _documentView = [[UIImageView alloc] init];
  16. [self addSubview:_documentView];
  17. [_documentView addSubview:_watermarkView];
  18. [_documentView addSubview:_rotationBtn];
  19. }
  20. return self;
  21. }
  22. - (void)layoutSubviews {
  23. [super layoutSubviews];
  24. [_watermarkView mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.center.equalTo(self);
  26. make.centerX.equalTo(self);
  27. make.centerY.equalTo(self);
  28. make.width.equalTo(@100);
  29. make.height.equalTo(@100);
  30. }];
  31. _watermarkView.layer.borderColor = UIColor.blackColor.CGColor;
  32. _watermarkView.layer.borderWidth = 2;
  33. _watermarkView.image = [UIImage imageNamed:@"btn_selected"];
  34. [_rotationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.equalTo(self.watermarkView).offset(90);
  36. make.bottom.equalTo(self.watermarkView).offset(10);
  37. make.right.equalTo(self.watermarkView).offset(10);
  38. make.left.equalTo(self.watermarkView).offset(90);
  39. make.width.equalTo(@20);
  40. make.height.equalTo(@20);
  41. }];
  42. _rotationBtn.layer.cornerRadius = 10;
  43. _rotationBtn.layer.masksToBounds = YES;
  44. _rotationBtn.layer.borderColor = UIColor.blueColor.CGColor;
  45. [_rotationBtn setBackgroundImage:[UIImage imageNamed:@"btn_selected"] forState:UIControlStateNormal];
  46. _documentView.frame = self.bounds;
  47. }
  48. @end