CStampButton.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // CStampButton.swift
  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 UIKit
  13. class CStampButton: UIView {
  14. var stampBtn: UIButton?
  15. var titleLabel: UILabel?
  16. override init(frame: CGRect) {
  17. super.init(frame: frame)
  18. stampBtn = UIButton()
  19. stampBtn?.layer.cornerRadius = 20
  20. stampBtn?.layer.masksToBounds = true
  21. if stampBtn != nil {
  22. addSubview(stampBtn!)
  23. }
  24. titleLabel = UILabel()
  25. titleLabel?.textColor = UIColor.white
  26. titleLabel?.backgroundColor = UIColor.clear
  27. if titleLabel != nil {
  28. addSubview(titleLabel!)
  29. }
  30. backgroundColor = UIColor.clear
  31. }
  32. required init?(coder aDecoder: NSCoder) {
  33. super.init(coder: aDecoder)
  34. }
  35. override func layoutSubviews() {
  36. super.layoutSubviews()
  37. stampBtn?.frame = CGRect(x: bounds.size.width - 40, y: 0, width: 40, height: bounds.size.height)
  38. titleLabel?.frame = CGRect(x: 0, y: 0, width: 120, height: bounds.size.height)
  39. }
  40. }