BaseTableViewCell.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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: "4c9ed8")
  30. //self.textLabel?.font = UIFont.italicSystemFontOfSize(18)
  31. self.textLabel?.font = UIFont.boldSystemFontOfSize(19)
  32. self.textLabel?.textColor = UIColor(hex: "ffffff")
  33. if let menuText = data as? String {
  34. self.textLabel?.text = menuText
  35. }
  36. }
  37. override public func setHighlighted(highlighted: Bool, animated: Bool) {
  38. if highlighted {
  39. self.alpha = 0.4
  40. } else {
  41. self.alpha = 1.0
  42. }
  43. }
  44. // ignore the default handling
  45. override public func setSelected(selected: Bool, animated: Bool) {
  46. }
  47. }