CStampCollectionViewCell.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // CStampCollectionViewCell.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 "CStampCollectionViewCell.h"
  13. #pragma mark - StampCollectionViewCell
  14. @interface CStampCollectionViewCell ()
  15. @end
  16. @implementation CStampCollectionViewCell
  17. - (instancetype)initWithFrame:(CGRect)frame {
  18. if (self = [super initWithFrame:frame]) {
  19. self.stampImage = [[UIImageView alloc] init];
  20. self.stampImage.backgroundColor = [UIColor clearColor];
  21. self.stampImage.contentMode = UIViewContentModeScaleAspectFit;
  22. [self.contentView addSubview:self.stampImage];
  23. self.contentView.layer.borderWidth = 0.5;
  24. self.contentView.layer.borderColor = [UIColor lightGrayColor].CGColor;
  25. }
  26. return self;
  27. }
  28. - (void)layoutSubviews {
  29. [super layoutSubviews];
  30. self.stampImage.frame = CGRectMake(10, (self.contentView.bounds.size.height - 50)/2,
  31. self.contentView.bounds.size.width - 20, 50);
  32. }
  33. @end
  34. #pragma mark - StampCollectionHeaderView
  35. @implementation StampCollectionHeaderView
  36. - (instancetype)initWithFrame:(CGRect)frame {
  37. if (self = [super initWithFrame:frame]) {
  38. self.backgroundColor = [UIColor colorWithRed:248.0/255.0 green:248.0/255.0 blue:248.0/255.0 alpha:1.0];
  39. _textLabel = [[UILabel alloc] init];
  40. _textLabel.textColor = [UIColor colorWithRed:36.0/255.0 green:36.0/255.0 blue:36.0/255.0 alpha:1.0];
  41. _textLabel.font = [UIFont systemFontOfSize:14.0];
  42. [self addSubview:_textLabel];
  43. }
  44. return self;
  45. }
  46. - (void)layoutSubviews {
  47. [super layoutSubviews];
  48. _textLabel.frame = CGRectMake(10, 0, self.bounds.size.width-20, 20);
  49. }
  50. @end
  51. #pragma mark - StampCollectionHeaderView1
  52. @interface StampCollectionHeaderView1()
  53. @property (nonatomic,retain) UIView * headerView;
  54. @property (nonatomic,retain) UIButton * textButton;
  55. @property (nonatomic,retain) UIButton * imageButton;
  56. @end
  57. @implementation StampCollectionHeaderView1
  58. - (instancetype)initWithFrame:(CGRect)frame {
  59. if (self = [super initWithFrame:frame]) {
  60. _headerView = [[UIView alloc] init];
  61. _headerView.backgroundColor = [UIColor clearColor];
  62. [self addSubview:_headerView];
  63. self.textButton = [UIButton buttonWithType:UIButtonTypeSystem];
  64. [_textButton setTitle:NSLocalizedString(@"New Text Stamp", nil) forState:UIControlStateNormal];
  65. [_textButton setTitleColor:[UIColor colorWithRed:36.0/255.0 green:36.0/255.0 blue:36.0/255.0 alpha:1.0] forState:UIControlStateNormal];
  66. [_textButton addTarget:self action:@selector(buttonItemClicked_AddText:) forControlEvents:UIControlEventTouchUpInside];
  67. _textButton.layer.borderWidth = 1;
  68. _textButton.layer.cornerRadius = 5;
  69. _textButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
  70. _textButton.titleLabel.adjustsFontSizeToFitWidth = YES;
  71. _textButton.layer.borderColor = [UIColor colorWithRed:17.0/255.0 green:140.0/255.0 blue:1.0 alpha:1.0].CGColor;
  72. [_headerView addSubview:_textButton];
  73. self.imageButton = [UIButton buttonWithType:UIButtonTypeSystem];
  74. [_imageButton setTitle:NSLocalizedString(@"New Image Stamp", nil) forState:UIControlStateNormal];
  75. [_imageButton setTitleColor:[UIColor colorWithRed:36.0/255.0 green:36.0/255.0 blue:36.0/255.0 alpha:1.0] forState:UIControlStateNormal];
  76. _imageButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
  77. _imageButton.titleLabel.adjustsFontSizeToFitWidth = YES;
  78. [_imageButton addTarget:self action:@selector(buttonItemClicked_AddImage:) forControlEvents:UIControlEventTouchUpInside];
  79. _imageButton.layer.borderWidth = 1;
  80. _imageButton.layer.cornerRadius = 5;
  81. _imageButton.layer.borderColor = [UIColor colorWithRed:17.0/255.0 green:140.0/255.0 blue:1.0 alpha:1.0].CGColor;
  82. [_headerView addSubview:_imageButton];
  83. self.backgroundColor = [UIColor colorWithRed:248.0/255.0 green:248.0/255.0 blue:248.0/255.0 alpha:1.0];
  84. _textLabel = [[UILabel alloc] init];
  85. _textLabel.textColor = [UIColor colorWithRed:36.0/255.0 green:36.0/255.0 blue:36.0/255.0 alpha:1.0];
  86. _textLabel.font = [UIFont systemFontOfSize:14.0];
  87. [self addSubview:_textLabel];
  88. }
  89. return self;
  90. }
  91. - (void)layoutSubviews {
  92. [super layoutSubviews];
  93. _headerView.frame = CGRectMake(0, 0, self.bounds.size.width, 80);
  94. _textButton.frame = CGRectMake(10, CGRectGetMinY(_headerView.frame)+10, (self.bounds.size.width-40)/2, 60);
  95. _imageButton.frame = CGRectMake(30 + (self.bounds.size.width-40)/2, CGRectGetMinY(_headerView.frame)+10, (self.bounds.size.width-40)/2, 60);
  96. _textLabel.frame = CGRectMake(10, CGRectGetMinY(_headerView.frame)+80, self.bounds.size.width-20, 20);
  97. }
  98. #pragma mark - Button Event Action
  99. - (void)buttonItemClicked_AddImage:(id)sender {
  100. if ([self.delegate respondsToSelector:@selector(addImageWithHeaderView:)]) {
  101. [self.delegate addImageWithHeaderView:self];
  102. }
  103. }
  104. - (void)buttonItemClicked_AddText:(id)sender {
  105. if ([self.delegate respondsToSelector:@selector(addTextWithHeaderView:)]) {
  106. [self.delegate addTextWithHeaderView:self];
  107. }
  108. }
  109. @end