CPDFHeadView.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // CPDFHeadView.m
  3. // PDFViewer
  4. //
  5. // Created by kdanmobile_2 on 2022/12/7.
  6. //
  7. #import "CPDFHeadView.h"
  8. @implementation CPDFHeadView
  9. - (instancetype)initWithFrame:(CGRect)frame {
  10. self = [super initWithFrame:frame];
  11. if (self) {
  12. _imageView = [[UIImageView alloc] init];
  13. _imageView.image = self.image;
  14. CALayer *layer = [_imageView layer];
  15. layer.borderColor = [[UIColor blackColor] CGColor];
  16. layer.borderWidth = 0.5f;
  17. [self addSubview:_imageView];
  18. _showLabel = [[UILabel alloc] init];
  19. [_showLabel setText:@"1"];
  20. _showLabel.font = [UIFont systemFontOfSize:6];
  21. [self.imageView addSubview:self.showLabel];
  22. }
  23. return self;
  24. }
  25. - (void)drawRect:(CGRect)rect {
  26. [super drawRect:rect];
  27. [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.top.equalTo(self.mas_top);
  29. make.left.equalTo(self.mas_left);
  30. make.width.mas_equalTo(self.image.size.width / 9);
  31. make.height.mas_equalTo(self.image.size.height / 9);
  32. }];
  33. [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  34. make.top.equalTo(_imageView.mas_top).offset(0.5);
  35. make.left.equalTo(self.imageView.mas_left).offset(0.5);
  36. make.height.mas_equalTo(10);
  37. make.width.mas_equalTo(20);
  38. }];
  39. }
  40. @end