ChartTableViewCell.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // ChartTableViewCell.swift
  3. // Naterade
  4. //
  5. // Created by Nathan Racklyeft on 2/19/16.
  6. // Copyright © 2016 Nathan Racklyeft. All rights reserved.
  7. //
  8. import UIKit
  9. public final class ChartTableViewCell: UITableViewCell {
  10. @IBOutlet weak var chartContentView: ChartContainerView!
  11. @IBOutlet weak var titleLabel: UILabel?
  12. @IBOutlet weak var subtitleLabel: UILabel?
  13. @IBOutlet weak var rightArrowHint: UIImageView? {
  14. didSet {
  15. rightArrowHint?.isHidden = !doesNavigate
  16. }
  17. }
  18. public var doesNavigate: Bool = true {
  19. didSet {
  20. rightArrowHint?.isHidden = !doesNavigate
  21. }
  22. }
  23. public override func prepareForReuse() {
  24. super.prepareForReuse()
  25. doesNavigate = true
  26. chartContentView.chartGenerator = nil
  27. }
  28. public func reloadChart() {
  29. chartContentView.reloadChart()
  30. }
  31. public func setChartGenerator(generator: ((CGRect) -> UIView?)?) {
  32. chartContentView.chartGenerator = generator
  33. }
  34. public func setTitleLabelText(label: String?) {
  35. titleLabel?.text = label
  36. }
  37. public func removeTitleLabelText() {
  38. titleLabel?.text?.removeAll()
  39. }
  40. public func setSubtitleLabel(label: String?) {
  41. subtitleLabel?.text = label
  42. }
  43. public func removeSubtitleLabelText() {
  44. subtitleLabel?.text?.removeAll()
  45. }
  46. public func setTitleTextColor(color: UIColor) {
  47. titleLabel?.textColor = color
  48. }
  49. public func setSubtitleTextColor(color: UIColor) {
  50. subtitleLabel?.textColor = color
  51. }
  52. public func setAlpha(alpha: CGFloat) {
  53. titleLabel?.alpha = alpha
  54. subtitleLabel?.alpha = alpha
  55. }
  56. }