123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // CPDFTextPreview.m
- // PDFViewer
- //
- // Created by kdan on 2022/11/18.
- //
- #import "CPDFTextPreview.h"
- #import "Masonry.h"
- @implementation CPDFTextPreview
- - (instancetype)initWithFrame:(CGRect)frame
- {
- if (self = [super initWithFrame:frame]) {
- _watermarkLabel = [[UILabel alloc] init];
- _rotationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _documentView = [[UIImageView alloc] init];
- [self addSubview:_documentView];
- [_documentView addSubview:_watermarkLabel];
- [_documentView addSubview:_rotationBtn];
- }
- return self;
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
- _watermarkLabel.layer.borderWidth = 2;
- _watermarkLabel.layer.borderColor = UIColor.blackColor.CGColor;
- _watermarkLabel.text = @"Watermark";
- _watermarkLabel.textColor = UIColor.redColor;
- _watermarkLabel.font = [UIFont systemFontOfSize:24];
-
- [_watermarkLabel sizeToFit];
- CGRect frame = _watermarkLabel.frame;
- frame.origin = CGPointMake(self.bounds.size.width / 2 - _watermarkLabel.frame.size.width / 2, self.bounds.size.height / 2 - _watermarkLabel.frame.size.height / 2);
- _watermarkLabel.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.watermarkLabel).offset(self.watermarkLabel.frame.size.height - 10);
- // make.bottom.equalTo(self.watermarkLabel).offset(10);
- // make.right.equalTo(self.watermarkLabel).offset(20);
- // make.left.equalTo(self.watermarkLabel).offset(self.watermarkLabel.frame.size.width);
- // make.width.equalTo(@20);
- // make.height.equalTo(@20);
- // }];
- _rotationBtn.frame = CGRectMake(self.bounds.size.width / 2 + _watermarkLabel.frame.size.width / 2 - 10, self.bounds.size.height / 2 + _watermarkLabel.frame.size.height / 2 - 10, 20, 20);
-
- _documentView.frame = self.bounds;
- _documentView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- }
- @end
|