// // CPDFImagePreview.m // PDFViewer // // Created by kdan on 2022/11/18. // #import "CPDFImagePreview.h" #import "Masonry.h" @implementation CPDFImagePreview - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _watermarkView = [[UIImageView alloc] init]; _rotationBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _documentView = [[UIImageView alloc] init]; [self addSubview:_documentView]; [_documentView addSubview:_watermarkView]; [_documentView addSubview:_rotationBtn]; } return self; } - (void)layoutSubviews { [super layoutSubviews]; [_watermarkView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self); make.centerX.equalTo(self); make.centerY.equalTo(self); make.width.equalTo(@100); make.height.equalTo(@100); }]; _watermarkView.layer.borderColor = UIColor.blackColor.CGColor; _watermarkView.layer.borderWidth = 2; _watermarkView.image = [UIImage imageNamed:@"btn_selected"]; [_rotationBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.watermarkView).offset(90); make.bottom.equalTo(self.watermarkView).offset(10); make.right.equalTo(self.watermarkView).offset(10); make.left.equalTo(self.watermarkView).offset(90); make.width.equalTo(@20); make.height.equalTo(@20); }]; _rotationBtn.layer.cornerRadius = 10; _rotationBtn.layer.masksToBounds = YES; _rotationBtn.layer.borderColor = UIColor.blueColor.CGColor; [_rotationBtn setBackgroundImage:[UIImage imageNamed:@"btn_selected"] forState:UIControlStateNormal]; _documentView.frame = self.bounds; } @end