BaseTableViewCell.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // BaseTableViewCell.swift
  3. // Gasteizko Margolariak
  4. //
  5. // Created by Inigo Valentin on 2016-08-23
  6. // Copyright © 2016 Inigo Valentin. All rights reserved.
  7. //
  8. // Based on the work of Yuji Hato.
  9. //
  10. import UIKit
  11. public class BaseTableViewCell : UITableViewCell {
  12. class var identifier: String { return String.className(self) }
  13. public required init?(coder aDecoder: NSCoder) {
  14. super.init(coder: aDecoder)
  15. setup()
  16. }
  17. override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
  18. super.init(style: style, reuseIdentifier: reuseIdentifier)
  19. setup()
  20. }
  21. public override func awakeFromNib() {
  22. }
  23. public func setup() {
  24. }
  25. public class func height() -> CGFloat {
  26. return 48
  27. }
  28. public func setData(data: Any?) {
  29. self.backgroundColor = UIColor(hex: "3344ff")
  30. self.textLabel?.font = UIFont.italicSystemFontOfSize(18)
  31. self.textLabel?.textColor = UIColor(hex: "000000")
  32. if let menuText = data as? String {
  33. self.textLabel?.text = menuText
  34. }
  35. }
  36. override public func setHighlighted(highlighted: Bool, animated: Bool) {
  37. if highlighted {
  38. self.alpha = 0.4
  39. } else {
  40. self.alpha = 1.0
  41. }
  42. }
  43. // ignore the default handling
  44. override public func setSelected(selected: Bool, animated: Bool) {
  45. }
  46. }