12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //
- // CPDFTextPreview.m
- // PDFViewer
- //
- // Created by kdan on 2022/11/18.
- //
- #import "PDFWatermarkTextPreview.h"
- #import "Masonry.h"
- BOOL gTextPreviewIsFirstLayout = YES;
- @implementation PDFWatermarkTextPreview
- - (instancetype)initWithFrame:(CGRect)frame
- {
- if (self = [super initWithFrame:frame]) {
-
- _rotationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
-
- [self.documentImageView addSubview:self.preLabel];
- [self.preLabel addSubview:_rotationBtn];
-
- self.backgroundColor = [UIColor grayColor];
- }
- return self;
- }
- #pragma mark - Drawrect
- - (void)drawRect:(CGRect)rect {
- [super drawRect:rect];
- self.preLabel.layer.borderWidth = 1;
- self.preLabel.layer.borderColor = UIColor.blueColor.CGColor;
- [self.preLabel sizeToFit];
-
- /*
- this have a core was delete:
- if (gTextPreviewIsFirstLayout) {
- gTextPreviewIsFirstLayout = NO;
- }
-
- */
- CGRect frame = self.preLabel.frame;
- frame.origin = CGPointMake(self.documentImageView.bounds.size.width / 2 - self.preLabel.frame.size.width / 2, self.documentImageView.bounds.size.height / 2 - self.preLabel.frame.size.height / 2);
- self.preLabel.frame = frame;
- _rotationBtn.layer.cornerRadius = 10;
- _rotationBtn.layer.masksToBounds = YES;
- _rotationBtn.layer.borderColor = UIColor.blueColor.CGColor;
- [_rotationBtn setBackgroundImage:[UIImage imageNamed:@"btn_selected"] forState:UIControlStateNormal];
-
- [_rotationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.preLabel.mas_bottom).offset(-15);
- make.width.equalTo(@30);
- make.height.equalTo(@30);
- make.left.equalTo(self.preLabel.mas_right).offset(-15);
- }];
- }
- @end
|