CSignatureTopBar.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // CSignatureTopBar.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 "CSignatureTopBar.h"
  13. @implementation CSignatureTopBar
  14. #pragma mark - Initializers
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. if (self = [super initWithFrame:frame]) {
  17. self.drawButton = [[UIButton alloc] init];
  18. self.drawButton.tag = 0;
  19. [self.drawButton setImage:[UIImage imageNamed:@"CPDFSignatureImageDraw" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
  20. [self.drawButton addTarget:self action:@selector(buttonItemClicked_swith:) forControlEvents:UIControlEventTouchUpInside];
  21. [self addSubview:self.drawButton];
  22. self.textButton = [[UIButton alloc] init];
  23. self.textButton.tag = 1;
  24. [self.textButton setImage:[UIImage imageNamed:@"CPDFSignatureImageText" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
  25. [self.textButton addTarget:self action:@selector(buttonItemClicked_swith:) forControlEvents:UIControlEventTouchUpInside];
  26. [self addSubview:self.textButton];
  27. self.imageButton = [[UIButton alloc] init];
  28. self.imageButton.tag = 2;
  29. [self.imageButton setImage:[UIImage imageNamed:@"CPDFSignatureImageImage" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
  30. [self.imageButton addTarget:self action:@selector(buttonItemClicked_swith:) forControlEvents:UIControlEventTouchUpInside];
  31. [self addSubview:self.imageButton];
  32. self.backgroundColor = [UIColor purpleColor];
  33. }
  34. return self;
  35. }
  36. - (void)layoutSubviews {
  37. [super layoutSubviews];
  38. self.drawButton.frame = CGRectMake(10, 0, 50, self.bounds.size.height);
  39. self.textButton.frame = CGRectMake(70, 0, 50, self.bounds.size.height);
  40. self.imageButton.frame = CGRectMake(130, 0, 50, self.bounds.size.height);
  41. }
  42. #pragma mark - Action
  43. - (void)buttonItemClicked_swith:(UIButton *)button {
  44. if (self.delegate && [self.delegate respondsToSelector:@selector(signatureTopBar:selectIndex:)]) {
  45. // [self.delegate signatureTopBar:self selectIndex:button.tag];
  46. }
  47. }
  48. @end