// // CPDFImagePreview.m // PDFViewer // // Created by kdan on 2022/11/18. // #import "PDFWatermarkImagePreview.h" #import "Masonry.h" BOOL gImagePreviewIsFirstLayout = YES; @implementation PDFWatermarkImagePreview - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _rotationBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [self.documentImageView addSubview:self.preImageView]; [self.preImageView addSubview:_rotationBtn]; } return self; } #pragma mark - Layout - (void)layoutSubviews { [super layoutSubviews]; 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); _watermarkFrame = frame; self.preImageView.frame = _watermarkFrame; [_rotationBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.preImageView.mas_bottom).offset(-10); make.width.equalTo(@20); make.height.equalTo(@20); make.left.equalTo(self.preImageView.mas_right).offset(-10); }]; _rotationBtn.layer.cornerRadius = 10; _rotationBtn.layer.masksToBounds = YES; _rotationBtn.layer.borderColor = UIColor.blueColor.CGColor; [_rotationBtn setBackgroundImage:[UIImage imageNamed:@"btn_selected"] forState:UIControlStateNormal]; } @end