CCustomizeStampTableViewCell.m 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // CStampCustomizeTableViewCell.m
  3. // ComPDFKit_Tools
  4. //
  5. // Copyright © 2014-2024 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 "CCustomizeStampTableViewCell.h"
  13. #if __has_include(<ComPDFKit_Tools/ComPDFKit_Tools.h>)
  14. #import <ComPDFKit_Tools/ComPDFKit_Tools.h>
  15. #else
  16. #import "ComPDFKit_Tools.h"
  17. #endif
  18. @interface CCustomizeStampTableViewCell ()
  19. @property (nonatomic, strong) UIButton *deleteButton;
  20. @end
  21. @implementation CCustomizeStampTableViewCell
  22. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  23. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  24. self.customizeStampImageView = [[UIImageView alloc] init];
  25. [self.contentView addSubview:self.customizeStampImageView];
  26. self.deleteButton = [[UIButton alloc] init];
  27. [self.deleteButton setImage:[UIImage imageNamed:@"CPDFSignatureImageDelete" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
  28. [self.deleteButton addTarget:self action:@selector(buttonItemClicked_delete:) forControlEvents:UIControlEventTouchUpInside];
  29. [self.contentView addSubview:self.deleteButton];
  30. self.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
  31. }
  32. return self;
  33. }
  34. - (void)layoutSubviews {
  35. [super layoutSubviews];
  36. CGFloat height = self.contentView.bounds.size.height-10;
  37. CGFloat width = height * (self.customizeStampImageView.image.size.width / self.customizeStampImageView.image.size.height);
  38. width = MIN(width, self.contentView.bounds.size.width - 80.0);
  39. [self.customizeStampImageView setFrame:CGRectMake((self.bounds.size.width - width)/2.0, 5.0, width, height)];
  40. self.customizeStampImageView.center = self.contentView.center;
  41. self.deleteButton.frame = CGRectMake(self.bounds.size.width - 50, 0.0, 50, 50);
  42. }
  43. #pragma mark - Action
  44. - (void)buttonItemClicked_delete:(id)sender {
  45. if (self.deleteDelegate && [self.deleteDelegate respondsToSelector:@selector(customizeStampTableViewCell:)]) {
  46. [self.deleteDelegate customizeStampTableViewCell:self];
  47. }
  48. }
  49. - (void)awakeFromNib {
  50. [super awakeFromNib];
  51. // Initialization code
  52. }
  53. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  54. [super setSelected:selected animated:animated];
  55. // Configure the view for the selected state
  56. }
  57. @end