CPDFSignatureViewCell.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // CPDFSignatureViewCell.m
  3. // compdfkit-tools
  4. //
  5. // Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. // This notice may not be removed from this file.
  11. //
  12. #import "CPDFSignatureViewCell.h"
  13. @implementation CPDFSignatureViewCell
  14. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  15. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  16. self.signatureImageView = [[UIImageView alloc] init];
  17. [self.contentView addSubview:self.signatureImageView];
  18. }
  19. return self;
  20. }
  21. - (void)layoutSubviews {
  22. [super layoutSubviews];
  23. CGFloat height = self.contentView.bounds.size.height;
  24. CGFloat width = height * self.signatureImageView.image.size.width / self.signatureImageView.image.size.height;
  25. width = MIN(width, self.contentView.bounds.size.width - 80.0);
  26. [self.signatureImageView setFrame:CGRectMake((self.bounds.size.width - width)/2.0, 0.0, width, height)];
  27. self.signatureImageView.center = self.contentView.center;
  28. }
  29. - (void)awakeFromNib {
  30. [super awakeFromNib];
  31. // Initialization code
  32. }
  33. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  34. [super setSelected:selected animated:animated];
  35. // Configure the view for the selected state
  36. }
  37. @end