CPDFPopMenuItem.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // CPDFPopMenuItem.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 CPDFPopMenuItem: UITableViewCell {
  14. var titleLabel: UILabel?
  15. var iconImage: UIImageView?
  16. private var splitView: UIView?
  17. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  18. super.init(style: style, reuseIdentifier: reuseIdentifier)
  19. titleLabel = UILabel.init()
  20. titleLabel?.font = UIFont.systemFont(ofSize: 17)
  21. if titleLabel != nil {
  22. contentView.addSubview(titleLabel!)
  23. }
  24. iconImage = UIImageView()
  25. if iconImage != nil {
  26. contentView.addSubview(iconImage!)
  27. }
  28. splitView = UIView()
  29. contentView.addSubview(splitView!)
  30. splitView?.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.12)
  31. }
  32. override func layoutSubviews() {
  33. super.layoutSubviews()
  34. iconImage?.frame = CGRect(x: self.frame.size.width - 36, y: (self.frame.size.height - 20)/2, width: 20, height: 20)
  35. titleLabel?.frame = CGRect(x: 20, y: 2.5, width: self.frame.size.width - 56, height: self.frame.size.height - 5)
  36. splitView?.frame = CGRect(x: 0, y: self.frame.size.height - 1, width: self.frame.size.width, height: 1)
  37. }
  38. required init?(coder: NSCoder) {
  39. fatalError("init(coder:) has not been implemented")
  40. }
  41. static func loadCPDFPopMenuItem() -> CPDFPopMenuItem? {
  42. let bundle = Bundle(for: self)
  43. return bundle.loadNibNamed("CPDFPopMenuItem", owner: nil, options: nil)?.last as? CPDFPopMenuItem
  44. }
  45. func hiddenLineView(_ isHidden: Bool) {
  46. self.splitView?.isHidden = isHidden
  47. }
  48. }