CPDFInfoTableCell.swift 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // CPDFDisplayTableViewCell.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. let kDocumentInfoTitle: String = "kDocumentInfoTitle"
  14. let kDocumentInfoValue: String = "kDocumentInfoValue"
  15. class CPDFInfoTableCell: UITableViewCell {
  16. var titleLabel: UILabel?
  17. var infoLabel: UILabel?
  18. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  19. titleLabel = UILabel(frame: .zero)
  20. infoLabel = UILabel(frame: .zero)
  21. super.init(style: style, reuseIdentifier: reuseIdentifier)
  22. // Configure the cell
  23. if(titleLabel != nil) {
  24. contentView.addSubview(titleLabel!)
  25. }
  26. if(infoLabel != nil) {
  27. contentView.addSubview(infoLabel!)
  28. }
  29. titleLabel?.backgroundColor = .clear
  30. titleLabel?.isOpaque = false
  31. titleLabel?.textColor = UIColor(red: 102/255, green: 102/255, blue: 102/255, alpha: 1)
  32. titleLabel?.highlightedTextColor = .lightGray
  33. titleLabel?.font = UIFont.boldSystemFont(ofSize: 13)
  34. titleLabel?.numberOfLines = 2
  35. titleLabel?.textAlignment = .left
  36. infoLabel?.backgroundColor = .clear
  37. infoLabel?.isOpaque = false
  38. infoLabel?.textColor = UIColor(red: 20/255, green: 96/255, blue: 243/255, alpha: 1)
  39. infoLabel?.highlightedTextColor = .lightGray
  40. infoLabel?.font = UIFont.boldSystemFont(ofSize: 13)
  41. infoLabel?.numberOfLines = 2
  42. infoLabel?.textAlignment = .right
  43. }
  44. required init?(coder aDecoder: NSCoder) {
  45. fatalError("init(coder:) has not been implemented")
  46. }
  47. override func layoutSubviews() {
  48. super.layoutSubviews()
  49. let contentRect = contentView.bounds
  50. titleLabel?.frame = CGRect(x: 16, y: -2, width: contentRect.size.width/2 - 16, height: contentRect.size.height)
  51. infoLabel?.frame = CGRect(x: contentRect.size.width/2 - 16, y: -2, width: contentRect.size.width/2, height: contentRect.size.height)
  52. }
  53. override func setEditing(_ editing: Bool, animated: Bool) {
  54. super.setEditing(editing, animated: animated)
  55. }
  56. override func setSelected(_ selected: Bool, animated: Bool) {
  57. super.setSelected(selected, animated: animated)
  58. }
  59. func setDataDictionary(_ newDictionary: [String: Any]) {
  60. titleLabel?.text = newDictionary[kDocumentInfoTitle] as? String
  61. infoLabel?.text = newDictionary[kDocumentInfoValue] as? String
  62. setNeedsLayout()
  63. }
  64. }